Claus Reinke claus.reinke at
Sun Sep 25 01:35:39 PDT 2011

> It's different when you have syntax:
> -----
> var o = {};
> var a2 = o <| [1, 2, 3];
> -----
> Here, the array syntax literal guarantees (since ES5, not in ES3!) that
> a native array is going to be built. Same goes for "function(){}" or any
> object created with reliable syntax, so the parser can both safely build
> the object and assign the chosen prototype.
> That's my interpretation though and i'd be happy to hear from others.

That would seem to call for <| to be a copying operator:

- if RHS is a literal, original object can still be safely updated in place
- if RHS is a non-literal object, a copy of that object is created and

According to the first point in the proposal comments:

the definition of cloning/copying is the show-stopper.

Not sure how that interacts with the RHS function literal special case.
I assume that if we had an accepted short function syntax, that special
case would not even exist. Instead, we'd use:

function(..args) { return (proto <| functionLiteral(..args) ); }

But I'm probably misunderstanding that special case anyway..


More information about the es-discuss mailing list