-
Notifications
You must be signed in to change notification settings - Fork 1.7k
introduce struct (lightweight class) #10374
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
Added Area-Language, Triaged labels. |
Depending on the order of the fields seems a little "un-dartlike" for me. Then you can do |
This comment was originally written by @tatumizer
|
This comment was originally written by @tatumizer I want to document Lasse's suggestion from mailing list. I think it's a beautiful idea. We follow the syntactic pattern of typedef for function here, instead of inventing new syntax. |
The appetite for syntactic sugar is unbounded, but it comes at a real cost. Every reader of the language, both human and mechanical, has to deal with all this extra stuff. Everyone who learns the language needs to learn each extra construct, and the manuals get bigger and bigger. The tools acquire feature upon feature and grow bloated. It's also a barrier to new tools. All of this is by way of explaining why keeping the language relatively small is much better than accommodating every potential feature. In this case, introducing a new construct so that one can avoid typing a constructor is in my judgement the wrong thing to do. It also has an opportunity cost; the cycles spent dealing with these issues come at the expense of dealing with more productive features, or improvements to existing ones. Nothing is free. |
This comment was originally written by @tatumizer I agree with that. The game is not worth the candle. |
I agree that sync* methods are of debatable value. They're there mainly for symmetry, and on the grounds that once you implement all the CPS like machinery for async, they don't add that much cost. But it is a judgement call. |
Is there something similar to inline classes in Dart? |
Yes I know this issue has closed. But you can use this method at dart 3. Read my answer at stack overflow. It supports nested types and I think it is more clear next to class type way. |
This issue was originally filed by @tatumizer
Please consider introducing struct (as lightweight class)
Example:
struct ABC { int a; String b; DateTime c; }
should be compiled into
class ABC {
int a;
String b;
DateTime c;
ABC(this.a, this.b, this.c){}
}
The text was updated successfully, but these errors were encountered: