Skip to content

Instantly share code, notes, and snippets.

@joliss
Created October 28, 2015 13:32
Show Gist options
  • Save joliss/dbb39a2151a1b4e7d085 to your computer and use it in GitHub Desktop.
Save joliss/dbb39a2151a1b4e7d085 to your computer and use it in GitHub Desktop.
// (I'm advocating for option -1, until we figure out the right solution,
// which is probably somewhere in the solution space of options 1/1a/2.)
// option -1: change nothing
// option 0: no inheritance, current proposal - breaks `class B extends A { }`,
// not really future-proof
// option 1: inheritance + just this incantation - ugliness for common case
class A {
call constructor(...args) {
return new function.target(...args);
}
...
// or
[Symbol.call](...args) {
return new function.target(...args);
}
}
// option 1a: inheritance + incantation + @callable decorator
// option 2: inheritance + option 1 + make it default for `class` - starts
// "religious war"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment