Am 25.04.2021 um 05:47 schrieb Larry Garfield <la...@garfieldtech.com>: > In practice, I think all of the use cases for sealed classes are ADT-esque. > As I noted before, combining sealed classes with Nikita's new-in-expressions > RFC would allow for this (also using my short-functions RFC for this example, > although that's a nice-to-have): > > sealed class Maybe permits Some, None {
... > } > > final class None extends Maybe {} This is exactly the thing I'm worried about. Say I want to add something like logging to the None type. Now your sealed and final classes prevent me from defining MyNone extending None even though it would be 100% compatible with None. Just because *you* deemed that useless or wrong. I've encountered situations like this and came to the conclusion that while this makes sense for languages like Haskell - where the whole idea is to be able to reason about a complex type system - it is an anti-pattern for other languages like PHP. Referring to another post, not yours: People, please don't use Java as a reason to add something to PHP, Java is the king of anti-patterns ;-) - Chris