4 ms·
you mean like in Oberon?
by eager_learner 2mo ago
you mean like in Oberon?
- whateveracct 2mo agoML's parametric polymorphism
- foldr 2mo agoGo lets you constrain type parameters with interfaces. To do anything analagous in SML you have to use functors, which is substantially less convenient. I think people who refer to ML's parametric polymorphism in this context must really be thinking of parametric polymorphism in OCaml or Haskell.
- whateveracct 2mo agoYou just do dictionary passing.
- foldr 2mo agoLike this, you mean? https://haskellforall.com/2012/05/scrap-your-type-classes https://haskellforall.com/2012/05/scrap-your-type-classes Fine in principle, but AFAIK it never really caught on because the ergonomics suck. Interfaces/traits/type classes do seem to be a popular feature across languages, for what it's worth.
- whateveracct 2mo agoright but type classes are basically vtables aka dictionary passing but the compiler figures out which dictionary to summon for you but the key is they build seamlessly on top of real parametric polymorphism. you still get a real "forall a." in your proposition language. Go fucked up early on with their core language design due to an inability to learn from the 1970s so now it's terminally dookie sadly
- foldr 2mo agoType classes are nice, yes, but SML doesn’t have them, or anything that can really stand in for Go’s interfaces.