Tennent's correspondence principle and loop-local variable capture

Jon Zeppieri zeppieri at gmail.com
Thu Jun 30 16:33:12 PDT 2011


On Thu, Jun 30, 2011 at 7:27 PM, Mark S. Miller <erights at google.com> wrote:
>
>
> On Thu, Jun 30, 2011 at 4:07 PM, Brendan Eich <brendan at mozilla.com> wrote:
>>
>> The old C-style for(;;) loop is a hard case. It really does want a single
>> shared-mutable loop control variable. Making 'let' instead of var in for
>> (let i = 0; i < N; i++) ... bind afresh on each iteration and communicate
>> the ++ update across the loop edge is theoretically doable, but it's wrong.
>
> Why is it wrong? I showed a de-sugaring of for(;;) into lambda that creates
> a separate binding per iteration. (I can try to find it in the es-discuss
> archive if it would be helpful.)
>

Because when I write i++ I expect mutation.

-Jon


More information about the es-discuss mailing list