On Mar 17, 2012, at 2:03 AM, Russell Leggett wrote:

> Given the recent go at finding alternative syntax for the <| operator, I 
> thought about it and decided to split the functionality between creating 
> "instances" using alternative prototypes, and the other side of the fence 
> making reusable extended objects easier to make.
> 
> Its a little long so I threw it in a gist: https://gist.github.com/2056771

I've already replied WRT : vs <| in another message so this is about the rest 
of the ideas in your gist.

Some of this feels like it is circulating  back to things we already discussed, 
for example at  
http://www.mail-archive.com/[email protected]/msg10365.html 

I also wanted to point out that there is another way to express object 
instantiation with arbitrary [[Prototype]].  It is the new <object> operator as 
described in 
https://mail.mozilla.org/pipermail/es-discuss/2011-September/016736.html 

Essentially,
     let proto = { ... };  //some literally defined object
     let instance = proto <| { };  //instance is new object with no own 
properties who [[Prototype]] is proto

could be expressed as 
     let instance = new proto; //instance is new object with no own properties 
who [[Prototype]] is proto

The only difference is that |new proto| would also apply an initialization 
function (proto's constructor property) on the new instance.

Other than that, the only real difference I see is that the "magic" you are 
applying regarding functions is different from that defined for <| but it is 
still treated as a special case. You magic is that if the LHS is a function you 
always use the value of its prototype property (BTW, what if it doesn't have 
one) as the [[Prototype]] value.   so if you say:
   (functtion f1() {}) : function f2() {}
the [[Prototype]] of f2 will be f1.prototype and f2 will not inherit at all 
from Function.prototype.  This doesn't seem right. 

If you just think about <| (or :) as an instantiation operator you still have 
to take into account what it means to have "function (,,,) {,,,}" on the RHS. 
The issue is that such a function express is actually instantiating two objects 
and they both need to get their [[Prototype]] values set to something 
reasonable.   I think that my <| definition supplies a more reasonable (fewer 
new user surprises) then your : definition.

Allen


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

Reply via email to