CS2 Discussion: Features: decorators

From @rattrayalex on July 23, 2016 2:51

Decorators are an increasingly popular feature of ES6, particularly with React development.

However, they use @atSyntax, which clashes with coffeescript’s this. shorthand.

We could:

  1. Come up with an alternative syntax for decorators
  2. Come up with a new syntax for this. shorthand
  3. Keep both as they are and just work hard to parse them
  4. Get rid of this. shorthand
  5. Don’t add decorators
  6. Any other ideas?

Thoughts?

Copied from original issue: coffeescript6/discuss#9

2 thoughts on “CS2 Discussion: Features: decorators

  1. Our policy is that we generally don’t support new syntax until it reaches Stage 4. That doesn’t mean we necessarily will support it at Stage 4, but the default assumption is that we will. The only reasons we wouldn’t would be if it somehow conflicted with something else in CoffeeScript, like how let/const conflicted with automatic variable declaration; or if we agree that the new feature was a terrible idea, though I hope by this point with the current process in place there shouldn’t be too many more “bad parts” entering JavaScript.

  2. The syntax also potentially problematic. I understand it looks like the decorator syntax from other languages, which is a pro, but it also looks like CoffeeScript’s this shorthand, even though it’s an unrelated feature. I would expect it to reference window or arguments or something similar to this.

    I’d expect @@whatever to translate to this.constuctor.whatever. Like a shorthand for accessing static class members.