All,
I was going to lurk longer before raising this, and apologies if it's been
raised before, but the discussion of object extension literals sort of
brought it up.
TL;DR: I wonder if the object extension literal might reasonably become a
fit-for-purpose `with`. For years I've thought the `with` problem could be
solved relatively easily by using a leading dot (not an original thought,
but I hesitate to even mention where I've seen it before -- VB) and
presumably a different keyword. Now I wonder if we don't even need a
keyword.
The detail:
The current strawman supports
o.{
a: "foo",
b = "bar"
};
...where the first is [[DefineOwnProperty]] and the second is [[Put]]. The
discussion has moved on a bit with people suggesting using semicolons and
allowing calls as well:
o.{
a: "foo";
b = "bar";
c.f(); // e.g., o.c.f()
};
or with parens:
o.(
a: "foo";
b = "bar";
c.f(); // e.g., o.c.f()
);
To me, that starts looking a lot like a series of statements rather than
definitions/assignments -- and specifically, a lot like `with`.
So that leads me to wonder about something along these lines:
o.{
.a: "foo"; // [[DefineOwnProperty]]
.b = "bar"; // [[Put]]
.c.f(); // E.g., o.c.f();
.d = .a; // E.g., o.d = o.a;
.x.{
.y = 2; // E.g., o.x.y = 2;
};
};
E.g., a combination of object extension literal and an improved `with`.
-- T.J.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss