3 ms·
I'm sure Java dis some things first, as I said. It's great that you mention some. >That's how we've been able to avoid properties and just have algebraic data
by DeathArrow 4y ago
I'm sure Java dis some things first, as I said. It's great that you mention some.
>That's how we've been able to avoid properties and just have algebraic data types
By algebraic data types you mean product types or sum types?
- wathef 4y agoBoth of those (sum and products) are ADTs.
- pron 4y agoBoth. Java has records for products, sealed hierarchies for sums, and offers pattern matching over them. See https://www.infoq.com/articles/data-oriented-programming-java/ https://www.infoq.com/articles/data-oriented-programming-jav...
- DeathArrow 4y ago>sealed hierarchies for sums I wouldn't call that a good example of sum types. You can use sealed classes or other mechanism in C# to emulate sum types. I was thinking about something built in the language. Example: type IntOrBool = | I of int | B of bool
- pron 4y agoIt's built into the language and the VM (the VM enforces the "sealedness", and pattern matching uses it for exhaustiveness checks). It's just that all types in Java are nominal.