On 31 May 2012 11:05, Jussi Kalliokoski <[email protected]> wrote:
> On Thu, May 31, 2012 at 12:52 PM, T.J. Crowder > <[email protected]>wrote: > >> On 31 May 2012 10:44, Andreas Rossberg <[email protected]> wrote: >> >>> On 30 May 2012 23:34, David Herman <[email protected]> wrote: >>> > On May 30, 2012, at 2:27 PM, Rick Waldron wrote: >>> > >>> > On Wed, May 30, 2012 at 5:22 PM, David Herman <[email protected]> >>> wrote: >>> >> >>> >> >>> >> array.{ >>> >> pop(); >>> >> pop(); >>> >> pop(); >>> >> }; >>> >> >>> >> path.{ >>> >> moveTo(10, 10); >>> >> stroke("red"); >>> >> fill("blue"); >>> >> ellipse(50, 50); >>> >> }; >>> >> >>> >> this.{ >>> >> foo = 17; >>> >> bar = "hello"; >>> >> baz = true; >>> >> }; >>> > >>> > >>> > This is beautiful and looks powerful -- will it still meet the most >>> > common/obvious use case? >>> > >>> > var div = document.createElement(). >>> > >>> > div.{ >>> > style.{ >>> > color = "red"; >>> > left = "100px"; >>> > } >>> > }; >>> > >>> > >>> > I didn't specify in my blog post. :) I'm open to it. I tend to find the >>> > nested syntax a little brain-exploding, but I understand the >>> motivation. >>> >>> Assuming you propose to allow things like o.{a.b = 6; c.f()} anyway, >>> then the above would actually fall out for free if you defined your >>> syntax as pure syntactic sugar, and do the rewriting in the natural >>> bottom up manner. >>> >>> /Andreas >> >> >> I'm worried this looks a lot like `with` -- with the same issues. Is the >> idea that unqualified references would be _required_ to be properties of >> the object in question? So >> > > I actually thought that this looks like `with` as well, but I don't share > your concerns, to me this looks like a fixed `with`. > > >> o.{ >> a.b = 6; >> c.f(); >> }; >> >> ...would work, but >> >> o.{ >> a.b = foo; >> c.f(); >> }; >> >> ...would throw (assuming there is no `foo` property)? >> > > I don't see a reason why it wouldn't throw, if I understood correctly. I > don't see why `foo` should have anything to do with `o`. IMHO, it's best if > only the left-hand side interacts with the object being extended, this way > we don't get the problems of `with`, i.e. scope being (near-)impossible to > measure and more minorly, easy leaked globals (e.g. var a = {}; with (a) { > foo = 'bar' } ). > > Cheers, > Jussi > So the idea is that only the left-hand side has the magic. Except that there doesn't always seem to _be_ a left-hand side (ref `c.f()` above), which makes this look at lot like some kind of block rather than a batch assignment/definition (since things aren't always being assigned/defined), and thus a lot like `with`. If we start introducing calls as well as assignments and property definitions. When things start looking like a series of statements, I'm worried we'll start reading them that way, and get things like this: o.{ a.b = 6; c.f(); a.b = a.c; // !! }; The expectation there (the last line) would surely be that both `a`s refer to the same thing. This problem exists now (and sometimes comes up) with regard to object literals, but object literals don't look much like a series of statements. This does. -- T.J.
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

