`with` revisited and related to object extension literals

David Herman dherman at mozilla.com
Fri Jun 1 10:02:13 PDT 2012

On Jun 1, 2012, at 2:54 AM, T.J. Crowder wrote:

> Hey, no stress -- always happy to have input. Just please, no more bogus comparisons to `with`.
> Could we please avoid derogatory terms like "bogus"? I'm talking about what people see when they look at code (more below). That's a valid argument. You can disagree with it without deriding it.

Not deriding; it wasn't clear to me that your argument had to do with perception rather than semantics. I was responding to the words you said ("that's with-lite", "acts like with"). I was trying to be friendly, and failed -- where I come from "bogus" is not derogatory, it just means "invalid" without being debate-club nerdcore. And I do take issue with the analogy to `with`. But I apologize for coming down too hard. These memes spread easily and they spread fast, so I really wanted to head off any confusion that we would *ever* specify something like `with`.

> > In the cascade proposal, the LHS of each item *contains no variables*.
> I didn't say it did.

It was your use of the word "free" that confused me -- see below...

> A freestanding `foo` outside the mustache is completely unrelated to a freestanding `foo` within the mustache. I get it.

Fair enough!

> I'm saying that's not what I see when I look at it, and not what I think most developers will see, because -- and correct me if I'm wrong, it's certainly been known! -- the only other place where that's true is an object initializer, isn't it? I believe everywhere else, an identifier that isn't a reserved word, standing free, is resolved via the scope chain.

Oh, you're using "free" in a different way than I'm accustomed to. (A "free variable" is a variable reference that is not bound, or not bound in a particular context.) That's part of what threw me off.

So yeah, your objection is similar to Mikeal Rogers' objection in the gist thread I linked to before:


I actually agree with that. The issue here is that to understand that the LHS of each item corresponds to the object rather than scope, you have to figure out that you're underneath a mustache. That's a reasonable objection.

I just take issue with the over-broad analogy to `with`. The problem with `with` is that it's statically undecidable whether any variable in the body is bound by the object or by something else in the scope chain.

> Apologies for apparently having given the impression I didn't understand how you defined cascades to work. We could have avoided some wasted time if I'd made that clear.

And I apologize for reacting so strongly. It's just that `with` is anathema to many JS developers (for good reason!), and it's an easy smear that gets used loosely to disregard proposals or even ES6 writ large.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120601/dd5ba9a7/attachment.html>

More information about the es-discuss mailing list