lexical for-in/for-of loose end
Andreas Rossberg
rossberg at google.com
Mon Feb 6 06:38:25 PST 2012
On 4 February 2012 21:55, Brendan Eich <brendan at mozilla.org> wrote:
> The argument is as follows:
>
> for (let i = 0, a = some.array, n = a.length; i < n; i++) { ... }
>
> here we definitely want the a in a.length (n's initializer) to be scoped by
> the head let -- to be the a declared by the second declarator.
>
> Now consider a bit of eta conversion:
>
> for (let i = 0, a = some.array, n = (function(){return a})().length; i < n;
> i++) { ... }
Nit: That is a beta-conversion, not an eta-conversion. ;-)
(Fortunately, because eta-conversions are not actually
semantics-preserving in an impure language.)
> I claim implementation is not the driver here. User expectations, esp. savvy
> users who might make some practical or theoretical (testing) use of eta
> conversion, matter more.
Agreed. As long as we don't spec something weird, the extra effort for
implementations shouldn't be much more than that of an extra block
around the loop body.
/Andreas
More information about the es-discuss
mailing list