-
Notifications
You must be signed in to change notification settings - Fork 213
[Wildcard Variables][spec] Allow super._
?
#3792
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
Comments
cc. @dart-lang/language-team |
super._
?super._
?
I doubt that any author will see this and have a chance for it to surprise them I don't think it would cause trouble at all to disallow The only member of a class which we should expend effort to allow naming |
@lrhn said:
I find myself agreeing with @lrhn here. It seems to me that if this works (which the spec says it does): class C {
var _;
C(this._); // OK.
} then it would be surprising for this not to work: class D extends C {
D(super._);
} @lrhn continued:
Interestingly enough, I went and looked back at the super-parameters spec, and as far as I can tell, it's not actually specified in terms of de-sugaring to a representation that uses the names. In point of fact, the semantics are directly specified in terms of the indices of positional parameters. E.g. there is this text:
So AFAICT there would be absolutely no problem, spec wise, if we went ahead and supported But even if there were, I would rather remedy such a problem by fixing the spec so that |
The point of class Point {
final int x, y;
Point(this.x, this.y);
}
class ColorPoint extends Point {
final Color color;
ColorPoint._(super._, super._, this.color);
// More constructors
} It's not something I expect to see a lot, public constructors should have descriptive names, but the point here is that the names are completely irrelevant to the language. ColorPoint._(super.banana, super.apricot, this.color); and it would work just as well. The name isn't important, so I can't give any good explanation for why using Which means that if we make it not work, we need to explain that to users, and if we just make it work, we have nothing to explain. |
Do we need to? I don't think any author will care why we disallow it. An explanation of "it was easier to implement" would be sufficient. The pattern shows up only twice in It's not obvious to me that disallowing it actually would be any easier to spec and implement, but I do think we should place much higher weight on that over the potential confusion of a tiny fraction of users who might see a diagnostic, or the even tinier fraction of users who will care when they do. |
I'm not worried about existing If the current specification hadn't singled out
(That is an easier specification.) So let's assume we replace the part about Does anyone then have a good reason to change that? If not, I think that's what the spec should say. (Of the two, |
Ideally,
|
My problem with that problem statement is that it doesn't tell me anything about how it actually works. So not a useful functional description. That's why I (try to) consistently talk about this feature as " It's fair to argue that
Being inaccessible and being ignored is not the same thing. An optional parameter named Or a That's what
I'm not making that claim. The name of a positional super parameter, or the name of the positional parameter it's forwarded to, has nothing to do with whether it's passed on or not. We allow |
The language team just decided that |
Updated the spec: ae95904. |
Let's talk about what we want to do with
super._
in this issue.Previous Discussion
Originally posted by @lrhn in #55661
Originally posted by @eernstg in #55661
Originally posted by @lrhn in #55661
The text was updated successfully, but these errors were encountered: