3 ms·
It shouldn't be that hard to add a 'variant' type to a statically typed language. In fact, OO languages usually just use a common superclass for just this purpo
by Retra 12y ago
It shouldn't be that hard to add a 'variant' type to a statically typed language. In fact, OO languages usually just use a common superclass for just this purpose.
- dllthomas 12y agoAnd of course Haskell now has Dynamic, it's just not very useful.
- Retra 12y agoIt's probably useful if you wanted to implement a dynamic language using Haskell. :P
- dllthomas 12y agoI'm not sure if this was intended in jest, but it's a bit interesting to treat it seriously so I'm doing so... I think it would not be a very good choice to implement a dynamic language in Haskell, because what it makes flexible is choice of Haskell type, and you likely don't want to tie implemented-language type to Haskell type like that. It would seem more likely to be useful if you wanted to host a dynamic language within Haskell.
- Roboprog 12y agoOr if you are "Go", you just make up an interface with a "quack" method (and maybe "walk", "swim" and "fly", too), without the concrete types ever knowing / caring that there was such an interface, all while still getting the needed type checking on the function/method calls.