Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make `super` consistent with ES6 #2638

Closed
paulmillr opened this Issue · 11 comments

7 participants

@paulmillr
  • Current CoffeeScript & Ruby super calls appropriate fn of the superclass with all arguments and super a, b, c for calling with other args.
  • ECMAScript 6 super is just a direct reference to the super class.
  • Coco & LiveScript super is just a direct reference to the super function.

I’m in favour of ES6-way which will be consistent with futurejs.

So, super should just be a ref to superclass. This will also allow to use it in static methods etc which will close gh-1790

@paulmillr paulmillr referenced this issue in michaelficarra/CoffeeScriptRedux
Closed

State of the project #106

@michaelficarra
Collaborator

+1.

@jashkenas
Owner

I'm afraid we're not targeting ES6 yet -- and at the time that CoffeeScript's super was defined, ES6's semantics weren't yet nailed down. I'm still not sure if their super is going to change before it begins to appear in browsers.

More importantly than that, I think our semantics are desirable. I think that languages that allow you to write:

method: ->
  super.otherMethod(1, 2, 3)

... are violating encapsulation. Your method implementation shouldn't have to know where in the inheritance hierarchy you need to call. super should only ever be an implementation detail of the current method. In addition, if you really need to apply a method from another object against this -- you can always do that manually with call and apply

@jashkenas jashkenas closed this
@paulmillr

actually I agree with jash’s args, almost never called other superclass methods in apps. But almost always calling super (without args and stuff).

@vendethiel
Collaborator

what about allowing super:: ?

@paulmillr

@Nami-Doc @constructor.__super__

@vendethiel
Collaborator

Seems overly ugly to me, doesn't it?

@jashkenas
Owner

Just name the external class -- like you usually would.

@vendethiel
Collaborator

I suppose that's the best way

@xixixao

One of the problems of implicit delegation: Default values for parameters don't work. I guess this could be fixed in Redux.

@satyr
Collaborator
  • ECMAScript 6 & Coco & LiveScript: super is just a direct reference to the super function.

Would be great if this were true. In reality it isn't that simple due to the implicit .call(this).

@lozandier

I don't know if it helps with CoffeeScripts eventual push to incorporate ES6 features once it's ratified (later this year?), but it seems CoffeeScript's super wouldn't need a change at all (at best minor):

nzakas/understandinges6#55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.