CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Implement super

Open mizchi opened this issue 10 years ago • 13 comments

It works in most cases but with memberAccessOp doesn't. I can't guess some specs. So I want to ask here.

mizchi avatar May 14 '14 20:05 mizchi

oh :).

vendethiel avatar May 14 '14 20:05 vendethiel

Excellent!

akre54 avatar May 14 '14 20:05 akre54

Fix by myself :) but I have no confidence it is correct way... in especially assignee detection.

@michaelficarra please give me advice, or merge if you don't care.

mizchi avatar May 15 '14 13:05 mizchi

There are still a few pending tests that could get squashed by this. The static super ref needs to reference __super__.constructor (CS), and some of the scope lookup stuff may need some streamlining. But awesome to get the main case out of the way on this!

akre54 avatar May 15 '14 15:05 akre54

I will implement static super too. After that I want to reply other peoples fix.

mizchi avatar May 16 '14 22:05 mizchi

Thanks for the PR, but there's a lot of work still needed here and, more importantly, I am still not sure of the future of super in CoffeeScript to begin with. Many, including myself, have been petitioning the other maintainers for adoption of ES6 semantics.

michaelficarra avatar May 19 '14 00:05 michaelficarra

Shouldn't CSR at least try to match CS super as it stands now, and then fix if CS changes? There hasn't been any progress on super in years and it's preventing many people (myself included) from switching to CSR.

akre54 avatar May 19 '14 13:05 akre54

Sure. I'd merge a PR that achieves that. We need all those tests I mentioned in place first, though.

michaelficarra avatar May 19 '14 15:05 michaelficarra

My private goal is that I want to make CSR which has compatibility to CS. (And for my hobby project TypedCoffeeScript that aimed to super set of CS, but you, execept me, don't have to take care about it:)

Anyway, I will fix some point you mentioned first. Thx!

mizchi avatar May 19 '14 17:05 mizchi

Now it works about super and static method super in class as CS specs.

mizchi avatar May 20 '14 17:05 mizchi

Oops, I passed only syntax and broke execution. I'll fix...

mizchi avatar May 21 '14 17:05 mizchi

+1 thanks @mizchi, this is a hugely important for me being able to move to CS-redux

notslang avatar Jun 27 '14 00:06 notslang

I incorporated this PR into my ES6 branch, so I can piggyback off the super keyword. It's working pretty well. Demo:

$ cat sample.coffee

class Foo extends Bar
  someValue: 1
  constructor: (a) ->
    super(a)
  doIt: ->
    super("yay")

$ ./bin/coffee --bare --js --input ./sample.coffee --target-es6

// Generated by CoffeeScript 2.0.0-beta9-dev-es6
class Foo extends Bar {
  constructor(a) {
    super(a);
  }
  doIt() {
    return super.doIt('yay');
  }
}
Foo.prototype.someValue = 1;

ef4 avatar May 27 '15 14:05 ef4