3 ms·
> He also said that there's no mechanism to compensate for the absence of duck typing. Whereas, in reality, there's a whole class of static type systems which
by masklinn 16y ago
> He also said that there's no mechanism to compensate for the absence of duck typing.
Whereas, in reality, there's a whole class of static type systems which do the same thing, except statically: structural type systems (example: OCaml's object types).
Much as duck typing, they only make sense for object-oriented languages. Structural type systems treat (concrete) objects and object types as method sets (where a method is a triple of name, argument types and return types), where, given the types A and B with A a structural subtype of B, A's methodset will be a superset B's methodset.
> I think that some Scala mechanisms provide that power.
Scala provides structural types (via type refinements) since 2.6.0: http://programming-scala.labs.oreilly.com/ch12.html#StructuralTypes http://programming-scala.labs.oreilly.com/ch12.html#Structur... http://scala.sygneca.com/patterns/duck-typing-done-right http://scala.sygneca.com/patterns/duck-typing-done-right