prototype focus

Mark S. Miller erights at google.com
Fri Jul 1 07:38:32 PDT 2011


On Fri, Jul 1, 2011 at 7:18 AM, Sean Eagan <seaneagan1 at gmail.com> wrote:

> On Fri, Jul 1, 2011 at 8:45 AM, Irakli Gozalishvili <rfobic at gmail.com>
> wrote:
>
> > why do I have to create constructor function for all classes / subclasses
> ?
>

This magic trades confusion for convenience. In any earlier version of the
proposal, I actually had a traditional default constructor, the equivalent
of

    constructor() { super(); }

but others argued against it. Sorry don't remember who. There were plenty of
off list discussions to gather consensus. On this one, I didn't feel
strongly either way, but I eventually agreed with the objectors. When in
doubt, throw it out -- even more important in language design than in
writing.



>
> This could be handled by class literals by allowing for default
> constructors.  If one doesn't provide a constructor, the following one
> could be provided:
>
> constructor(... args) {
>  super(... args);
> }


This one I object to because those used to other languages that provide such
default constructors will only call the super constructor with no arguments.
Though now that you mention it, I can see why JSers without exposure to
other languages may naturally expect your's.

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.

-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110701/f1475055/attachment-0001.html>


More information about the es-discuss mailing list