On Tue, May 29, 2012 at 11:03 AM, Brendan Eich <[email protected]> wrote:
> Tab Atkins Jr. wrote:
>> I'm not making the assumption that "obj" in the examples is
>> necessarily an Object with Object.prototype. It's irrelevant to the
>> two points I'm trying to make:
>>
>> 1. The use-case for mustache is to replace current code that does a
>> lot of property-assigning statements with a more concise expression.
>>
>> 2. Devs will generally be surprised by [[DefineOwnProperty]] behavior,
>> since it's not observably different from [[Put]] in current code
>> except in some degenerate cases that aren't seen in non-adversarial
>> scenarios.
>
>
> Fair points so far, and why Dave Herman proposed using = and ; separation
> for a "fluent style" chaining extension:
>
> obj.{
> prop1 = val1;
> ...
> propN = valN;
> };
>
> Dave's proposal (which I can't find atm, it may be in a gist) also supports
> method calling with obj as |this|, a la JQuery chaining style but without
> requiring the methods to all return |this|.
I'm totally down with Dave's "weak 'with', only better" proposal.
Dave's syntax made it look like a special kind of block with a
restriction on what kind of statements were allowed. Because of this,
it felt very natural to also have method-calling in there. Since this
is really useful, this made me happy.
I'm also okay with it overlapping with the shadowing mustache. We
already have the literal vs block syntax fight, and this doesn't seem
to confuse authors (outside of funny talks about the return value of
{}+[]...) - reproducing the same fight within mustache doesn't seem
particularly bad, as long as things really do look and act like block
vs literal.
I honestly find it slightly weird that the shadowing mustache is a
mutator rather than returning a new object, but I wouldn't fight it.
(In other words, I find the proto-of arrow a slightly more natural
syntax to think of in this circumstance.)
~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss