Referencing `super`

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Aug 5 22:18:41 PDT 2014


use of unqualified super in this manner has a long history in OO programming language.  It’s too late this evening for me to dig up references for you but it dates to at least language designs of the early 1980.  Smalltalk didn’t do it, but mainly because it does doesn’t use a function invocation notation for method method calls.

The the early Smalltalk develpment experience clearly showed that methods almost always do super invokes of the same method name as the caller.  Unqualified super is a shorthand  for this most common.  It is so common, that I always react to seeing a qualified super invocation as a very exceptional case that I should look very closely at to understand why a something other than the current method is being super invoked.

The need to qualify super with a different method name is so rare, that some languages support nothing but unqualified super. But there are a few situations were it is quite useful and it is worth having in an OO programming language.  It’s kind of ironic that I recall previous discussions during the development of the ES6 class design where I had to justify why we should allow super to be qualified with a property name.

Allen





On Aug 5, 2014, at 9:50 PM, Rick Waldron <waldron.rick at gmail.com> wrote:

> 
> 
> 
> On Wed, Aug 6, 2014 at 12:38 AM, Rick Waldron <waldron.rick at gmail.com> wrote:
> 
> 
> On Tuesday, August 5, 2014, Domenic Denicola <domenic at domenicdenicola.com> wrote:
> I sympathize; I have always found the fact that bare `super()` works to be confusing.
> 
> When a bare super() call appears in a method (whether constructor or not) it can only have _one_ _meaning_ and that's a call to a method of the same name in the parent class. This isn't particularly innovative:
> 
> Note: I don't mean to imply that any of the examples I gave here are innovative either, they all copy the design (in a quasi-super-via-API way) and semantics that exist in other languages and I'd bet specifically Ruby. (Python requires the fully qualified name, which should be proof that JS has it right by allowing both forms)
> 
> Rick
> 
> John Resig's Simple JavaScript Inheritance[0]—arguably one of the most widely used (many clones, forks and spin-offs exist) "abstract class" techniques—provides `this._super()` which does the same thing that ES6 super() does. This pattern existed before and has been repeated throughout many libraries that have stood out over the years: Prototype, Dojo, Ext.js and certainly others. CoffeeScript implements super() this way as well. 
> 
> 
> Rick
> 
> 
> [0] http://ejohn.org/blog/simple-javascript-inheritance/
> 

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


More information about the es-discuss mailing list