Claude Pache (2014-02-03T19:09:21.000Z)
domenic at domenicdenicola.com (2014-02-05T19:43:17.308Z)
Le 3 févr. 2014 à 19:39, Brandon Benvie <bbenvie at mozilla.com> a écrit : > I like the motivation, but doing it as an early error is problematic (having experienced a validator that differentiates between `return`, `return undefined`, and `return void expr` and complains loudly). > > Instead I would suggest to throw an error at runtime if a class constructor returns anything besides undefined when it is constructed. I don't see much advantage in being allowed to write `return someExpressionThatShouldYieldUndefined`. Indeed, you can always write `someExpressionThatShouldYieldUndefined; return`, or even: `if (someExpressionThatShouldYieldUndefined !== undefined) throw new TypeError; return`. Also, the problem, with runtime exception, is that we are no longer able to easily differentiate between `construct` methods that are defined using the `class` syntax and other `construct` methods... which raise the issue of backward compatibility.