On May 31, 2012, at 2:52 AM, T.J. Crowder wrote:

> I'm worried this looks a lot like `with` -- with the same issues.

Nooooo. No.

This does not involve the object with the scope chain in any way.

> Is the idea that unqualified references would be _required_ to be properties 
> of the object in question? So
> 
> o.{
>     a.b = 6;
>     c.f();
> };
> 
> ...would work, but
> 
> o.{
>     a.b = foo;
>     c.f();
> };
> 
> ...would throw (assuming there is no `foo` property)?

No. The object is used for the (syntactically restricted, i.e., non-expression) 
LHS, but not the RHS expression. The object is not added to the scope chain.

> I keep meaning to propose a new `with` (different keyword, obviously) that 
> solves the `with` issues by using a leading dot -- but I wanted to lurk a 
> while beforehand, can't imagine it's an original thought (esp. as I used 
> _some_ language in the 90s that did that).

You're thinking of VB. I agree it was a better design than JS's `with`. But 
it's unfortunately a non-starter for adding to JS, because it introduces a new 
ASI hazard:

    with (obj) {
        foo() // no semi
        .bar = 12
    }

Dave

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

Reply via email to