new instantiation design alternatives

Herby Vojčík herby at mailbox.sk
Wed Sep 17 07:25:09 PDT 2014



Domenic Denicola wrote:
>
>
> On Sep 17, 2014, at 7:10, "Kevin Smith" <zenparsing at gmail.com 
> <mailto:zenparsing at gmail.com>> wrote:
>
>>
>>     That seems fine. Enabling different behaviour for called vs.
>>     constructed should only be used to explain the builtins; user
>>     code should not do so themselves. So it makes sense to me that
>>     those trying to do that would get "punished" with having to type
>>     more.
>>
>>
>> Yes, but if we guide users toward "this = new super", we actually 
>> change the current paradigm where the constructors can be called or 
>> new'd.
>>
>> As an example, this:
>>
>> function C() { B.call(this) }
>>
>> functions perfectly well as an object initializer, with or without "new".
>
> That's not true, is it? Assuming someone (e.g. B) actually assigns a 
> property of `this`, an error will occur (or worse, a global will be 
> created, in sloppy mode).

Maybe Kevin meant "can be new'd to create and initialize, and can be call'd just to
 initialize the existing one".



More information about the es-discuss mailing list