I'll have to agree with David Morgan.
There is no simple and generally applicable solution to automatically
generating equality/hashCode.
I, for one, would never put a runtimeType check into the equality, but
others ask for exactly that feature.
It seems that what you really need is a way to specify how you define
equality, in a domain specific language where you can describe it more
concisely than just writing the code, and then have the equality/hashCode
generated for you. That's not great as a language feature - we don't want a
highly specialized sub-language just for that - and the generalization of
it is something like macros, which is not a likely feature (again, it would
be another sub-language that you have to read in order to read Dart, it's
not just S-expressions like in Scheme).
So, unlikely as a language feature on normal classes. If we get value-types
of some sort, it might make more sense, but that depends entirely on how
they work out. It's entirely too soon to say anything specific, even
whether value types will exist at all.
That comes back to code generation. Something like that exists already,
e.g., in the built-values package, but the fact that they don't do what
everyone wants is just another proof that there isn't one universal
solution. If you have specific needs, you need specific tools to fulfill
them.
So, no current plans for auto-generated equality on classes as a language
feature.
/L
On Fri, Aug 26, 2016 at 3:50 PM, 'David Morgan â¯' via Dart Misc <
Post by 'David Morgan â¯' via Dart MiscI'm afraid nobody is working on a language feature or trying to make a
language feature happen.
I understand your frustration, it sounds like it would be a great thing to
have. But the details are hard, and we already have a solution that works.
If you want to influence or contribute to that solution, please look at the
codegen possibilities.
Post by kcHave you guys - Dart, Fuschia/Flutter, Angular/Ads - considered holding a
workshop to nail down these issues (as part of Dart 2.0).
I'm easy on a solution as long as the result is a Google consensus giving
a good dev experience and a good user experience re performance.
K.
Post by 'David Morgan â¯' via Dart MiscI tried to explain on the bug, but since you asked I will try again here :)
Note, I'm not on the Dart team, so please take this as opinion. I do
however have a lot of experience with implementing tools that do this kind
of generation, and they have significant use inside google. I'm currently
building open source equivalents of these tools, of which
https://github.com/google/built_value.dart is most relevant to this
question.
1) Is easy to solve with codegen, as in built_value.dart. If all you
want is operator== and hashCode then you can probably do this in a day.
2) Is hard to solve as a language feature. There are too many options.
Why stop at operator== and hashCode, why not also toString? What about
serialization? At some point you're likely to want codegen anyway, and then
you could have easily taken care of operator== and hashCode.
So I really think it doesn't make sense to ask for a language feature.
The focus right now should be on codegen. Any language feature requests
right now should be about improving the codegen story.
It _might_ make sense to promote a popular codgen-based solution to a
language feature, but only if it's used by such a huge proportion of Dart
developers that it's clear it belongs in the language. That's not going to
happen for a long time. And it's not going to happen at all unless people
explore the codegen options.
Cheers
Morgan
Post by kchttps://github.com/dart-lang/sdk/issues/26703
The Flutter team raised this - as have many folks on this group (who
have some modicum of taste when it comes to language design).
Is this going anywhere? The github conversation just petered out.
K.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Lasse R.H. Nielsen / ***@chromium.org
'Faith without judgement merely degrades the spirit divine'
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.