Claus Reinke wrote:
 var Blah = BaseClass <| function(){}
Blah.prototype.{
a: function(){},
b: function(){}
}

let Blah = BaseClass <| function() {
}.prototype.(
a() {},
b() {}
}.constructor.{};

1. I don't like the imperative approximations of a declarative API.
Since we're designing new language features, approximations
should not be necessary.

There have been suggestions to interpret '<|' declaratively,
and to avoid the special case for function rhs, ie, to interpret
(p <| obj) simply as a structural representation of an object with
un-nameable '[[prototype]]' field containing p.

You mean ditching function RHS completely or just not having it to specially treat LHS being function as well?

What were the arguments against this?

2. JS claims to be prototype-based but the 'prototype'-field really
points to shared traits, while the actual cloning of prototypes into
It's probably too late to rename it to instanceTraits (I find the name 'prototype' unhappy, too)
objects happens in the constructor functions. A deviation
from Self (if I recall that correctly), it is a source of confusion.

If we combine the two points (cloning happens in the constructor,
<| declares 'prototype' field), we get something like:

var Blah = function(){
return BaseClass <| {
a: function(){},
b: function(){}
}
}

I'd say no to this -- ES is classless, but not true prototype oriented. I would keep the constructor-function-as-the-class-and-factory-at-once. Even if it is not optimal, but I think it is the cornerstone of ES object model.

Claus

Herby

P.S.: I would not be against <| being much more declarative, even if you deny function RHSes from being <|-able (but why? function may want to have prototype other than Function.prototype, too; and not only for "class-inheritance"); but only if there would be other possibility to do the "class-inheritance", that, double chain (constructor->constructor as well as prototype->prototype).

function Sub (params) extends Super { body }

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

Reply via email to