es-discuss Digest, Vol 52, Issue 58

Axel Rauschmayer axel at rauschma.de
Tue Jun 14 23:25:11 PDT 2011


> From: Allen Wirfs-Brock <allen at wirfs-brock.com>
> Date: June 15, 2011 7:08:19 GMT+02:00
> To: es-discuss <es-discuss at mozilla.org>
> Subject: Prototypes as the new class declaration
> 
> 
> In https://mail.mozilla.org/pipermail/es-discuss/2011-June/015090.html I described how self uses an explicit copy method on prototypes to construct instance objects and summarized the difference between self and JavaScript in this regard as:
> 
>> So, there is pretty much a directly correspondence between a self copy method and a JavaScript constructor function.  However, there is definitely a difference of emphasis seen here.  In self, it is the prototype object that is the focus of attention.  In traditional JavaScript it is the constructor object.
> (emphasis added)
> 
>  In response to a reply from Axel I further said:
> 
>> A prototype P, as used in self, does seem to frequently subsume the role of a class.  A constructor  generally corresponds to the copy method of such a prototype.
> 
> Having thought about this a bit more, I'm beginning to think that perhaps we could get by without the proposed class declarations.


Cool! That’s what I meant when I wrote the following:

> From: Axel Rauschmayer <axel at rauschma.de>
> Date: June 13, 2011 10:55:56 GMT+02:00
> To: Allen Wirfs-Brock <allen at wirfs-brock.com>, es-discuss <es-discuss at mozilla.org>
> Subject: Re: Classes: suggestions for improvement
> 
>> The correspondence is not quite that straight forward.  A prototype P, as used in self, does seem to frequently subsume the role of a class.  A constructor  generally corresponds to the copy method of such a prototype.
> 
> Isn’t that the illusion that class literals aim to create? That a class is actually a single construct, an object C with a method construct() and that you can apply the new operator to that object? new C(x,y) would perform the following steps:
> 
> - Create a new instance o whose prototype is C.
> - Invoke o.construct(x,y)
> 
> Maybe "initialize" would be a better name than "construct", then.
> 
> Couldn’t that illusion be turned into how things are actually done?

-- 
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/20110615/f1ece1b3/attachment.html>


More information about the es-discuss mailing list