Using monocle mustache for chaining.

David Herman dherman at mozilla.com
Fri Nov 11 17:22:28 PST 2011


On Nov 11, 2011, at 4:18 PM, Rick Waldron wrote:

> Dave, if nesting were out of the question and monocle-mustache operator always looked like an object literal as they currently exist, would it still be as vile? With that form, I'm a big fan.

I'm of multiple minds (a condition I'm gradually getting accustomed to).

1) I'm really against the current syntax, because it hides the fact that it's a mutation. Assignments masquerading as declarative forms bring out Angry Dave (you wouldn't like me when I'm angry...)

2) I like it better if it includes "=" in it, e.g.:

    obj .= { foo: 1, bar: 2 };

3) But that makes me really wish for a more general expression form, so I could also do e.g.:

    obj1 .= obj2;

I've even written up a strawman for it:

    http://wiki.ecmascript.org/doku.php?id=strawman:batch_assignment_operator

4) Allen has pointed out that this is problematic for private names. For many use cases, it'd be fine if .= just didn't copy any private names -- done. But Allen's class pattern wanted to be able to specify private names. So he restricted the RHS to look like a literal.

5) Still, I have to say, the restricted RHS just seems ad hoc and unsatisfying.

Anyway, I'm still mulling.

Dave



More information about the es-discuss mailing list