-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[es6-super-construct] default constructor body for null extends #22
Comments
Not really. You also have to evaluated the function definition for the constructor at the same logical point in the program. So you can use the value of the extends clause to select which of two possible constructor function expression to evaluate. That's exactly what the ES6 spec currently describes. Here is a possible "compilation" of %extendsValue = foo;
%ctor = %extendsValue ===null ? function() {} : function( ){ your translation of "super(...Arguments)"};
%ctor.prototype.__proto__ = %extendsValue===null ? null : %extendsValue.prototyype;
If (%extendsValue!==null) %ctor.__proto__= %extendsValue;
//%ctor is the value of the function expression. Something I will have to look further at is to make sure that there aren't any early error dependencies upon the extends clause value. |
@allenwb Am I understanding correctly that an 'extends null' class would have |
@wycats That's right.
|
ES6 is done, doing some housecleaning! |
On Jan 9, 2015, at 7:43 AM, Erik Arvidsson wrote:
Happy New Year!
(I don't know which thread is the active thread.)
https://github.com/tc39/ecma262/blob/master/workingdocs/ES6-super-construct%3Dproposal.md
Point 12: If a class definition does not include an explicit constructor definition, it defaults to: constructor(...args) {super(...args)}; if the class has a non-null extends clause. Otherwise it defaults to: constructor() {};.
This is problematic since we have to evaluate the extends expression to know if it is null or not. This means that the default constructor needs to be:
constructor(...args) {
if (%extendsValue !== null) super(...args);
}
where %extendsValue is the result of evaluating the extends expression and it has to be captured for later references.
erik
The text was updated successfully, but these errors were encountered: