<| ambiguity

# Herby Vojčík (14 years ago)

Hello,

I have read some articles on wiki.ecmascript.org as well as some post here. It seems <| operator (which I only recently understood that it was probably meant to be the generalization arrow hollow top turned sideways :-) ) is used two ways.

As I understand, it was proposed (and I am with this semantics) so as proto <| obj is roughly equivavlent with Object.create(proto)... // with elements of obj added

But I saw many uses like

Car <| { ... } Car <| class Truck {...} Truck <| { ... }

where Car and Track are classes (constructor methods), not prototypes.

So which is the right semantics?

Thanks, Herby

P.S.: Maybe have two operators, <| for Object.extend semantics and <<|, <|| or <|= for the "raw instantiating" / subclassing one?

# Brendan Eich (14 years ago)

Please see harmony:proto_operator -- the <| operator grammatically requires only literal object forms on its right.

# Herby Vojčík (14 years ago)

Hello,

of course it does matter, when taken as a whole. I just wanted to say that the actual problem I was trying to address, that <| is to be used with prototypeObject, not with ClassConstructorFunction on the left side, is a problem if the left side, and literal (or not) is the right-side, which is another topic.

(and sorry for the mistake I only posted the previous mail to you not to the list since I clicked on "Reply" not "Reply to all")

Herby

P.S.: and it seems I slipped the word, too, "I would like to see it a little" should be "I would like to see it a little extended". :-/

-----Pôvodná správa---

# Brendan Eich (14 years ago)

No problem with re-posting a reply that you meant to be a reply-all.

For the case of

ClassConstructorFunction <| function (...) {...}

the proposal does something exra: it makes the RHS.prototype (the 'prototype' property of the RHS) delegate via that object's [[Prototype]] internal property to ClassConstructorFunction.prototype. So you get the parallel prototype and class-side inheritance:

RHS --[[Prototype]]--> ClassConstructorFunction --[[Prototype]]--> Function.prototype RHS.prototype --[[Prototype]]--> ClassConstructorFunction.prototype --[[Prototype]]--> Object.prototype

(assuming ClassConstructorFunction is a user-defined function whose .prototype is a fresh Object instance, as usual).

# Herby Vojčík (14 years ago)

Oh, thanks.

I am sorry I had not read the proposal to the full detail. I just thought the operator always does the same thing no matter what the context is, but since it is not general, but tied only to some syntactic elements on RHS ({}, [], function, ...) than it is understandable that it can do slightly different things for them.

I also apologize to those authors whom I charged with incorrect use of <|. It was me who was mistaken.

Herby

-----Pôvodná správa---