On 21 March 2012 20:05, Allen Wirfs-Brock <[email protected]> wrote:

> On Mar 21, 2012, at 10:11 AM, Brendan Eich wrote:
>  > Andreas Rossberg wrote:
> >> Right, but my comment was only about checking of assignments to const
> variables. Those are always an error, regardless of TDZ behaviour.
> >
> > Agreed, absolutely. In all-strict code we know all the bindings, we see
> all assignments.
>
> Yes, but just because a function is strict doesn't mean that everything is
> strict:
>
> {const c=0;
>  with (someObj) {
>     (function() {"use strict"}; c=2})();
>  }
> }
>

Note that I specifically said that the respective _declaration_ has to be
in strict code. That is not the case in your example. If the declaration is
in strict code, then no 'with' or 'eval' can intervene between the
declaration and its use (except for the potential issue with indirect eval
and the toplevel that I mentioned, but which should be solvable).

I prefer algorithmic specifications over prose but I think it would add too
> much complexity to the spec.


I agree, but this one is rather straightforward to spec, clearly delimited,
and not dependent on fancy analysis.



> to algorithmically  specify when an early error must be reported on
> assignments that may target const bindings. In this case I think the best
> we can do will be something like:  If it can be statically proven prior to
> execution that an assignment will always result in an ReferenceError the
> error may be reported as an early error.
>

Yes, I completely agree that introducing implementation-dependent behaviour
like that doesn't sound like a good idea.

/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to