prototype focus

Axel Rauschmayer axel at rauschma.de
Fri Jul 1 02:56:27 PDT 2011


What I’m asking for is the following (and I might not convince anyone, but just consider the possibility):

If you are using a constructor function C only once, during construction and otherwise always use C.prototype, wouldn’t it be better to focus on
        C' = C.prototype
Then you would use C'.constructor (or C'.initialize or C'.init) once and C' the remaining times.

To paraphrase: Hasn’t the prototype been always the core construct? And if yes, shouldn’t we make that explicit?

I would like people to agree with me that there is *some* merit in that. After that, there are still arguments against PAC, though...

As for __proto__: Have you taken a look at the <| operator? It does everything you want, it’s really cool.

On Jul 1, 2011, at 11:21 , Tim Smart wrote:

> I quite the current prototype model we have in ecma5. My only gripes would be that `prototype` to too wordy, and `__proto__` needs to become standard. If you replaced `prototype` with `::` or something everything would be swell.
> 
> function Parent (name) {
>   this.name = name || this.constructor.DEFAULT_NAME
> }
> Parent.DEFAULT_NAME = 'bob'
> 
> function Child (name, age) {
>   Parent.call(this, name)
>   this.age = age
> }
> Child.__proto__ = Parent
> Child::__proto__ = Parent.prototype
> Child::describe = function () {
>   return 'I am called ' + this.name + ' and I am ' + this.age + ' years old'
> }

-- 
Dr. Axel Rauschmayer

axel at rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110701/4a3c0f8a/attachment.html>


More information about the es-discuss mailing list