message-format-wg
message-format-wg copied to clipboard
Hoisting local variables or not
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
I'd prefer to not allow for that.
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: @.***>
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 ...}
+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.
In case if was not clear already :-) +1 for not hoisting.
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.