rainforestapp / decaf

Coffeescript to ES.next transpiler. Now maintained over at
https://github.com/juliankrispel/decaf
MIT License
106 stars 10 forks source link

Private statements #129

Closed juliankrispel closed 8 years ago

juliankrispel commented 8 years ago

In coffee-script it's entirely legal to just have random statements inside a class definition.

class A
  b()
  a + 1

This is what the compiler spits out:

var A;

A = (function() {
  function A() {}

  b();

  a + 1;

  return A;

})();

The only idea I have for this so far is to also wrap the es6 class in a self-invoked function

eventualbuddha commented 8 years ago

It's pretty bad, though, because you could do stuff like this:

class A
  @set = (key, value) -> @[key] = value
  @set 'log', (message) -> console.log('A says', message)
  @log 'foo'
juliankrispel commented 8 years ago

@eventualbuddha the feature in itself is pretty bad. I'm thinking about just throwing an error telling the user to fix