message-format-wg icon indicating copy to clipboard operation
message-format-wg copied to clipboard

Hoisting local variables or not

Open mihnita opened this issue 3 years ago • 4 comments

Example:

let $foo = {$bar :number ...}
let $bar = {$count :number ...}

Is there a good use case for $foo to be able to refer to $bar? I can't think of one. Some programming languages do this, some don't, and I don't think those that don't have major problems.

Not allowing it would make things simpler:

  • you don't have to wait until everything is defined to validate and report errors
  • prevents circular references

Forked as a sub-issue from https://github.com/unicode-org/message-format-wg/issues/292

mihnita avatar Sep 15 '22 15:09 mihnita

I'd prefer to not allow for that.

zbraniecki avatar Sep 15 '22 19:09 zbraniecki

Agreed. You can't use a variable until it is defined.

On Thu, Sep 15, 2022, 12:11 Zibi Braniecki @.***> wrote:

I'd prefer to not allow for that.

— Reply to this email directly, view it on GitHub https://github.com/unicode-org/message-format-wg/issues/297#issuecomment-1248501860, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJLEMADD6VFOD4MKAGXQ4TV6NYEPANCNFSM6AAAAAAQNQTI6U . You are receiving this because you are subscribed to this thread.Message ID: @.***>

macchiati avatar Sep 16 '22 13:09 macchiati

I'm okay with not hoisting, as long as referring to variables defined earlier is considered valid:

let $bar = {$count :number ...}
let $foo = {$bar :number ...}

eemeli avatar Sep 17 '22 19:09 eemeli

+1 to not hoisting as well.

Also, I note that this is a revisitable decision, just in case we learn about use-cases for hoisting in the future. Not hoisting today is forward-compatible with hoisting in the future.

stasm avatar Sep 23 '22 06:09 stasm

In case if was not clear already :-) +1 for not hoisting.

mihnita avatar Oct 16 '22 21:10 mihnita

as long as referring to variables defined earlier is considered valid:

I think that is still open to discuss (https://github.com/unicode-org/message-format-wg/issues/292) And not so much about if we should allow it (I think we should), but HOW we do it.

mihnita avatar Oct 16 '22 21:10 mihnita