coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

Quick access to prototype in "this" context and calling any super methods

Open applejohnny opened this issue 14 years ago • 1 comments

Hello! I want to offer a shorter record for prototype access in "this" context

Animal@say 'gaf!' instead of Animal::say.call this, 'gaf!', which compiles to

Animal.prototype.say.call(this, 'gaf!');

Moreover sometimes I need to call method of superclass, not related to the current function.

So inside method of subclass, super@say 'gaf!' - can be compiled to

Animal.prototype.say.call(this, 'gaf!');

where Animal is superclass

applejohnny avatar Oct 12 '12 06:10 applejohnny

See previous tickets -- we try to avoid adding too much sugar around call and apply, as they're already very usable APIs for setting the context of a function. The assumption that you'd want to reference the .prototype in this suggestion is problematic.

jashkenas avatar Oct 23 '12 21:10 jashkenas