Re:How Class-based Programming Sucks (2011)
by pjmlp on Saturday December 14, 2013 @03:02AM
(#6905093)
You can have OO without classes.
I just meant OO in general, not classes specifically.
Re:How Class-based Programming Sucks (2011)
by emn13 on Tuesday December 17, 2013 @06:04PM
(#6924623)
You can have Objects without classes, certainly - even C had structs, and all functional languages I know of have records or something similar.
It's a question of terminology whether you call that object-oriented. It's certainly part of OO, in any case.
Discriminated unions on the other hand are - the name says it - intended for cases where you want to discriminate between multiple possible values. They're by design not intended to hide differences behind an interface; they don't address the same problem at all.
All in all, I think that neither classes nor discriminated unions solve the interface problem (nor were they ever really designed to do so) - that's a different problem.