prototype focus

Irakli Gozalishvili rfobic at gmail.com
Fri Jul 1 15:06:10 PDT 2011




Regards
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/
Address: 29 Rue Saint-Georges, 75009 Paris, France (http://goo.gl/maps/3CHu)


On Friday, 2011-07-01 at 23:51 , Brendan Eich wrote:

> On Jul 1, 2011, at 8:40 AM, Irakli Gozalishvili wrote:
> > 
> > On Friday, 2011-07-01 at 16:38 , Mark S. Miller wrote:
> > 
> > > With two expectations for the semantics of something that does not appear in the code, and without a static or dynamic rejection to prevent progress of the code written to the wrong assumption, I now finally feel strongly about this. The critics were right -- we should not provide any default constructor. Thanks for pointing out the problem case.
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> > 
> > Do you think prototype focused version:
> > 
> > Prototype.new(foo);
> > 
> > also suggest wrong assumptions ?
> 
> What's the constructor protocol here? If I don't implement Prototype.new or Prototype.constructor, then what in the super-prototype is called, with what arguments?
> 
> 

It was stupid to assume it was obvious :)
I think this is a best answer: https://github.com/Gozala/selfish/blob/master/selfish.js

Or short version is

var Prototype = {
 new: function() {
var object = Object.create(this);
 object.initialize.apply(object, arguments);
return object;
 },
 initialize: function() {}
} 

var Point = Prototype <| {
initialize: function (x, y) {
this.x = x
this.y = y
} 
}

var point = Point.new(11, 17)

There are more examples here:
https://github.com/Gozala/selfish


> >  If not (which I think is the case) is another + in favor of prototype focus. 
> This scoring is silly. 


Agreed :)

> The trouble with OOP default-constructor protocols is there are so many of them. Having none, as Mark points out, avoids trouble. Having a different one from any in the language as conventionally used (including built-ins, DOM, etc.), even with prototype focus, does not guarantee anything.
> 
> As Axel has acknowledged, any .new protocol will coexist with constructor.prototype, forever. 


I'm more optimistic about, because currently it's a pain and I think any better alternative will win. 

> Adding explicit super-constructor calling is part of the classes deal, whatever the focus (constructor or prototype). Defaulting the super-constructor call or even the constructor implementation is trouble.
> 
> /be

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110702/878b057b/attachment-0001.html>


More information about the es-discuss mailing list