3 ms·
Yeah, it is very unfortunate that languages that have sum types each call them slightly different things: - sealed classes/interfaces - discriminated unions
by yen223 2y ago
Yeah, it is very unfortunate that languages that have sum types each call them slightly different things:
- sealed classes/interfaces
- discriminated unions
- enums
- case classes
It would be nice if we could agree on a single term to describe this, the same way we standardised on "class" to describe, well, classes.
- louthy 2y ago> the same way we standardised on "class" Did we, when did this happen? Languages like Haskell use type-class to mean something closer to traits/interfaces in other languages. I wouldn't be surprised if other languages have their own definition of what 'class' means. > to describe, well, classes. What is a class? Not trying to be an arse here, genuinely, what is it? In OO languages it would be a type with a collection of named-members. How is that different to a record with fields that are either data-types or first-class functions? Is inheritance implied? If so, what's a 'sealed class'? What does 'class' really mean? Classification? Doesn't the type-name alone classify something? Really, 'class' is the weird one imho; it's just everyone's so used to it now that it seems correct. It's similar with other OO terminology like 'object'. On the surface it seems sensible, but when you really think about it, it's kinda odd. Ultimately, we all just end up being most comfortable with what we know.