Finding a "safety syntax" for classes

Mark S. Miller erights at google.com
Tue Mar 20 22:32:20 PDT 2012


I have always been suspicious of static method inheritance. Smalltalk-76
did not have it. Smalltalk-80 did. Although I only ever had hands on with
Smalltalk-80, I always felt that Smalltalk-76 had this one right. I know
other smalltalkers disagree.

I think in a de-novo language like Dart or Smalltalk at the time, they are
at least plausible. So I find it interesting that Dart chose to avoid them.
For JS, I think they are disastrous because of "this" confusions. Normally,
when a JS method is "static", what we implicitly mean is that it is to be
found on a constructor function, and that the method does not depend on its
this-binding. For static method inheritance to make sense, many static
methods would instead be written to be this-sensitive. This will cause
common usage patterns to break.

For JS, because of its this-binding rules and the programming patterns that
have adapted to these rules, I believe it is too late for static
inheritance. But even if it weren't, I suspect it's a bad idea anyway.


On Tue, Mar 20, 2012 at 10:24 PM, Kevin Smith <khs4473 at gmail.com> wrote:

> We can live quite nicely with treating class declaration like const
>> declarations.  The name is logically hoisted so it is visible over the
>> lexical scope, but the name is temporally dead until the class declaration
>> is executed, in statement sequence, as an initializer.
>>
>
> This looks good to me.
>
> Personally I think the answer should be "A" which implies that we have
>> class-side inheritance.
>>
>
> I'm still trying to form an opinion on this.  Dart has no static method
> inheritance.  In the spec, there's the following commentary:
>
> *Inheritance of static methods has little utility in Dart. Static methods
> cannot*
> *be overridden. Any required static function can be obtained from its
> declaring*
> *library, and there is no need to bring it into scope via inheritance.
> Experience*
> *shows that developers are confused by the idea of inherited methods that
> are not*
> *instance methods*
>
>
> I'd be interested to hear other viewpoints on the matter.
>
> kevin
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


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


More information about the es-discuss mailing list