You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getter declarations no longer require/allow parentheses: int get foo=> 42;
Setter declarations have an = sign after the identifier: set foo=(int x);
The name of a setter for purposes of reflection and noSuchMethod is id=, whereas the getter is just id. This allows a standard, reliable way to distinguish them by their names just like any other method.
The obvious path here is to make the getter parens optional, and likewise the setter = sign. The internal names can be fixed at this time as well. Then fix the libs, then disallow parens on getters and make the = required on setters
Note that this also eliminates to compile-time error situations: there is no need to check that the formal parameter list of a getter is empty, since there is no parameter list. Also, a setter name can never conflict witha getter or method name, so no need to check for such a conflict either.
is perfectly legal. The example using => is just one example. ANd yes, +> is not part of the getter name - the getter name is always an identifier (at least for now - we are likely to view [] as a getter soon - fun details to follow).
The 0.11 draft gives the syntax, which is unchanged except that no formal parameter list is allowed in a getter signature, and an extra = sign is introduced before the formal parameter list in a setter signature.
Once the change is done, there will be fewer compiler checks and things should be ever so slightly simpler and cleaner. Rejoice!
I really don't get this change. Syntactically, it's an ugly change. You already have the "set" keyword to indicate that it's a setter function, so why do you need to have an = as well? I am guessing there is some logical reason for this choice that has something to do with the mirrors system, but why couldn't function mirrors just include some sort of flag on them like isSetter? I'm guessing because then you'd have two functions in the mirror with the same name and only a boolean flag to differentiate them. Still it seems like the syntax is being uglified because there is an issue in implementing mirrors for it and I don't like the resulting compromise.
then the following paragraph in 3.1:
It is a compile-time error if there is more than one entity with the same
name declared in the same scope, with the exception of the operator-, where
both a unary and a binary version may coexist.
needs to be changed back to include setters and getters among the exceptions, right?
Activity
gbracha commentedon Jun 13, 2012
The obvious path here is to make the getter parens optional, and likewise the setter = sign. The internal names can be fixed at this time as well. Then fix the libs, then disallow parens on getters and make the = required on setters
gbracha commentedon Jun 13, 2012
Note that this also eliminates to compile-time error situations: there is no need to check that the formal parameter list of a getter is empty, since there is no parameter list. Also, a setter name can never conflict witha getter or method name, so no need to check for such a conflict either.
gbracha commentedon Jun 13, 2012
Spec'ed in 0.11 draft.
Added Done label.
gbracha commentedon Jun 13, 2012
Analyzer issue #3607.
VM issue #3608.
dart2js issue #3609.
DartBot commentedon Jun 13, 2012
This comment was originally written by @mhausner
Is get foo { ...statements here...; return value }
legal syntax, or did we introduce a situation where the two forms of function blocks (=> and { }) are not interchangeable anymore?
I presume the => in get foo=> 42; is a separate token, not part of the getter name, despite the lack of a space in the example above.
gbracha commentedon Jun 13, 2012
get foo { ...}
is perfectly legal. The example using => is just one example. ANd yes, +> is not part of the getter name - the getter name is always an identifier (at least for now - we are likely to view [] as a getter soon - fun details to follow).
The 0.11 draft gives the syntax, which is unchanged except that no formal parameter list is allowed in a getter signature, and an extra = sign is introduced before the formal parameter list in a setter signature.
Once the change is done, there will be fewer compiler checks and things should be ever so slightly simpler and cleaner. Rejoice!
DartBot commentedon Jul 10, 2012
This comment was originally written by er...@codesmithtools.com
I really don't get this change. Syntactically, it's an ugly change. You already have the "set" keyword to indicate that it's a setter function, so why do you need to have an = as well? I am guessing there is some logical reason for this choice that has something to do with the mirrors system, but why couldn't function mirrors just include some sort of flag on them like isSetter? I'm guessing because then you'd have two functions in the mirror with the same name and only a boolean flag to differentiate them. Still it seems like the syntax is being uglified because there is an issue in implementing mirrors for it and I don't like the resulting compromise.
DartBot commentedon Jul 20, 2012
This comment was originally written by @tomaszkubacki
setter "=" seems really ugly and i agree with #7 smeels like a bad compromise. Can't mirros really workaround this somehow ?
peter-ahe-google commentedon Aug 15, 2012
Alas, no rejoice. AFAIK, the new setter syntax was abandoned. So no = in the setter name.
DartBot commentedon Aug 16, 2012
This comment was originally written by rodion...@unipro.ru
then the following paragraph in 3.1:
It is a compile-time error if there is more than one entity with the same
name declared in the same scope, with the exception of the operator-, where
both a unary and a binary version may coexist.
needs to be changed back to include setters and getters among the exceptions, right?
Bump pub to b9afe9270c24d040b8ae465b4b37ba4f7f4b4cc5