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
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

