Finding a "safety syntax" for classes

Herby Vojčík herby at mailbox.sk
Wed Mar 21 12:09:38 PDT 2012



John J Barton wrote:
> On Wed, Mar 21, 2012 at 11:52 AM, Russell Leggett
> <russell.leggett at gmail.com>  wrote:
>> On Wed, Mar 21, 2012 at 2:47 PM, Allen Wirfs-Brock<allen at wirfs-brock.com>
>> wrote:
>>>
>>> On Mar 21, 2012, at 8:41 AM, Russell Leggett wrote:
>>>
>>>
>>>
>>> On Wed, Mar 21, 2012 at 11:12 AM, Kevin Smith<khs4473 at gmail.com>  wrote:
>>>>> I think its easier to explain - it will actually result in a constructor
>>>>> on the prototype.
>>>>> The actual constructor function and the .constructor property really
>>>>> should always be in sync - this helps with that.
>
> So the proposal is that the class body declares a function called
> "constructor" in with other functions that will end up on the
> [[Prototype]] but the instance created from 'new' operating on the
> class function call will have an own property "constructor" that
> points to this function. Will the property also appear on the
> [[Prototype]] under 'constructor'?

No, it is same as existing reality. Do not read "the .constructor 
property" from above as "own .constructor property" (which may have led 
to your conclusion) but as "shared-via-prototype .constructor property", 
which is exactly the current status quo.

That's the beauty of 'constructor' named prototype/instance method - the 
status quo is such that it already is there, though it is created nehind 
the scenes as the magic of making a function also a constructor. So by 
using it nothing new is added.

> jjb

Herby


More information about the es-discuss mailing list