Structural types #21984
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
closed-not-planned
Closed as we don't intend to take action on the reported issue
type-enhancement
A request for a change that isn't a bug
This issue was originally filed by [email protected]
What would you like to see instead?
I really like the idea of Go interfaces. (Classes do not have to declare what interfaces they support. An interface is a set of methods. Any class that has those methods implements the interface.)
A lot of type checking in Dart is done at runtime anyways. It would be nice if a language user could take an advantage of it. The type system could allow expressing properties that are not nominal and static, but more like structural runtime asserts.
Please provide any additional information below.
Using an example given by Miško Hevry in https://www.youtube.com/watch?v=lGdnh8QSPPk while introducing AtScript [1] @15:00, I'd like to declare a type CssSelector which would be satisfied by anything of type String if the string matches a given Regexp.
Even though those properties are not static, an IDE could still take some limited advantage of it for code completion, during debugging and so on.
Related issue "Is the Dart type system is nominal?" #7639
[1] https://docs.google.com/document/d/11YUzC-1d0V1-Q3V0fQ7KSit97HnZoKVygDxpWzEYW0U/edit
The text was updated successfully, but these errors were encountered: