`with` revisited and related to object extension literals

T.J. Crowder tj at crowdersoftware.com
Fri Jun 1 03:09:02 PDT 2012


On 1 June 2012 06:05, Brendan Eich <brendan at mozilla.org> wrote:

> Brendan Eich wrote:
>
>> you're just rehashing a concern based on appearances
>>
>
> which (I want to be clear; sorry for harshing on the 'with' point) is a
> valid concern. We should discuss it directly, no 'with'-semantics mixed in.
>
> /be
>

Yes, very useful. I'll stick to things like "to me, the syntax makes it
look like those identifiers would be resolved via the scope chain" and
such. Won't mention `with`.

I'm a bit worried that people may have thought I was being derisive by
talking about `with`, and that that may have raised hackles. I wasn't. I
don't think `with` is a flawed concept at all (I recognize many do), so I
don't use it derisively. I agree with, I think, the majority here including
(if I'm not mistaken) your own good self that JS's original `with` had
serious issues, which in my view were down to it using freestanding
identifiers, intermixing object property resolution and scope chain
resolution. But I have no problem with the _concept_ in a different form.

So in summary and (largely) in closing:

1. I quite like the _idea_ of the cascade proposal, because like Dave (I
think?) I find the way cascades are currently done (a'la jQuery, via
`return this`) less than ideal.

2. My concerns with it relate to freestanding identifiers and how that
_looks_. See earlier note to Dave.

3. I think that concern can be dealt with without going to a `with`-like
structure.

4. I also think they could be dealt with via a new `with`-like structure
that did not put an object at the top of the scope chain, but instead
introduced a placeholder token for the object reference as purely syntactic
sugar (~. or similar). To me there's a lot of use there, including
cascades. But I seem to be alone. :-) I find that a bit odd, given how
similar to that the goals of the cascade sugar seem to be, but if I'm on my
own, I'm on my own.

Best,

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


More information about the es-discuss mailing list