4 ms·
I'm really not a fan of Dart's type system. It feels ancient to me. From what I can tell, there's no sum types, I don't see any way to bound generics based on i
by leshow 8y ago
I'm really not a fan of Dart's type system. It feels ancient to me. From what I can tell, there's no sum types, I don't see any way to bound generics based on interface/typeclasses/traits or some other equivalent concept on the docs, it has no non-nullable types. Am I wrong? Why would I want to use a type system that lacks expressiveness?
- munificent 8y ago> From what I can tell, there's no sum types Paraphrasing Qc Na: Subclasses are a poor man's sum type. Also, sum types are a poor man's subclasses. :) But, yes, some nicer notation for declaring a sealed family of types would be nice along the lines of case classes in Scala. It's something we've talked about a bunch but haven't had time to get to yet. > I don't see any way to bound generics based on interface/typeclasses/traits It uses the same syntax as Java: class Foo<T extends Bar> { T thing; method() { thing.methodOnBar(); } } > it has no non-nullable types. Not yet. :( I hope we can get to them.
- leshow 8y ago> Paraphrasing Qc Na: Subclasses are a poor man's sum type. Also, sum types are a poor man's subclasses. One of the great things about disjointed unions is (usually) exhaustiveness checking. Not to mention usually some form of pattern matching. Case classes would do the trick. It would be interesting to see those features in Dart, congrats on the release.