Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make super consistent with ES6 #2638

Closed
paulmillr opened this issue Dec 6, 2012 · 11 comments
Closed

Make super consistent with ES6 #2638

paulmillr opened this issue Dec 6, 2012 · 11 comments

Comments

@paulmillr
Copy link

  • 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

@michaelficarra
Copy link
Collaborator

+1.

@jashkenas
Copy link
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

@paulmillr
Copy link
Author

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
Copy link
Collaborator

what about allowing super:: ?

@paulmillr
Copy link
Author

@Nami-Doc @constructor.__super__

@vendethiel
Copy link
Collaborator

Seems overly ugly to me, doesn't it?

@jashkenas
Copy link
Owner

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

@vendethiel
Copy link
Collaborator

I suppose that's the best way

@xixixao
Copy link
Contributor

xixixao commented Dec 6, 2012

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

@satyr
Copy link
Collaborator

satyr commented Dec 7, 2012

  • 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
Copy link

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
Projects
None yet
Development

No branches or pull requests

7 participants