On 1 June 2012 01:40, Brendan Eich <[email protected]> wrote:

> Let's be precise. You keep bringing 'with' up but it's not relevant to the
> cascade proposal, going by Dave's definitions. If you have the "appearance
> of 'with'" concern I call out above, let's argue about that. It's a good
> one (again it is why I preferred () a day or so ago).


Yes, that's my concern. Something that looks almost exactly like the old
`with`, complete with implicit magic free symbol resolution, worries me. I
"keep" bringing up `with` because it's implicit in the proposals. It's not
something I'm adding, I'm just shining a light on it. This is more true of
the cascade than object extension literals, but the inclusion of things
that look like assignments in object extension literals makes it true of
them as well.

The only place that immediately comes to mind where free symbols aren't
currently resolved relative to the scope chain is the property name
literals in object initializers, and they have a sufficiently distinct
syntax (using the colon) that they're fairly distinct.

Separating the two distinct things (extension literals and cascade) out:

Object extension literals:

var a = "foo";
o.{
    a = "bar"
};

The lack of any kind of qualifier on the `a` makes it problematic, to my
mind. Yes, there's that special .{ ... } syntax, but it's at a sufficient
remove from the assignment that it's asking for trouble. Perhaps this could
be solved without a `with`-like structure by using something other than =,
to maintain the distinct nature that object initializers have. E.g.,

var a = "foo";
o.{
    a:  "bar",  // [[DefineOwnProperty]]
    b:= "baz"   // [[Put]]
};

Now it doesn't look like an assignment any more. It echoes object
initializer syntax. You could even read := as "define or put". And it has
the advantage it could be harmlessly back-fitted on object initializers
(er, I think -- I'm not a grammar god like AWB).

Now the cascade:

array.{
    pop()
    pop()
};

That looks like `with`, it acts like `with`, and it seems to have the same
motivation as `with`: To avoid writing `array` repeatedly. (I'm with Dave
on his point about the fragility of function chaining, btw.) I understand
that the proposal for it says `pop` must be resolved relative to `array`
(unlike `with`, where it could be anywhere on the scope chain), but it's
just way too similar. If we're going to do `with`, let's do it. I might
want to avoid writing `array` repeatedly on the RHS, too. (No RHSs in the
above, granted.)

Anyway, faced with two proposals with `with`-like features, it seemed
reasonable to point that out, to suggest how the issues with both could be
resolved with an explicit form of `with`. I'm a big fan of explicitness,
and a big fan of using a single solution to address multiple goals. But
it's just one way to go.

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

Reply via email to