So we can have our cake and eat it too with a tail-recursive
desugaring that forwards the previous iteration's binding value to
the next iteration's binding. [...]
Yeah, I got lost in the thread and missed the subtlety of that follow-
up. I'm having a hard time seeing any downside, other than perhaps a
mild inconsistency between var and let behavior here. Worth it, just
as long as any form with the general syntax of
'for' and 'for each' are the only loop constructs with that syntax. In
the other loop constructs ('while' and 'do..while'), the content of the
parentheses is an Expression, so no 'let' or 'const' declaration is allowed
at that level (and declarations within nested blocks are unproblematic).
For non-loop constructs the issue doesn't arise.
Neil Mix wrote:
> Brendan Eich wrote:
>> So we can have our cake and eat it too with a tail-recursive
>> desugaring that forwards the previous iteration's binding value to
>> the next iteration's binding. [...]
>
> Yeah, I got lost in the thread and missed the subtlety of that follow-
> up. I'm having a hard time seeing any downside, other than perhaps a
> mild inconsistency between var and let behavior here. Worth it, just
> as long as any form with the general syntax of
>
> <keyword> ( ... <let declaration/assigment> ... ) { <body> }
>
> behaves in the same manner.
'for' and 'for each' are the only loop constructs with that syntax. In
the other loop constructs ('while' and 'do..while'), the content of the
parentheses is an Expression, so no 'let' or 'const' declaration is allowed
at that level (and declarations within nested blocks are unproblematic).
For non-loop constructs the issue doesn't arise.
--
David-Sarah Hopwood
Neil Mix wrote:
'for' and 'for each' are the only loop constructs with that syntax. In the other loop constructs ('while' and 'do..while'), the content of the parentheses is an Expression, so no 'let' or 'const' declaration is allowed at that level (and declarations within nested blocks are unproblematic). For non-loop constructs the issue doesn't arise.