2 ms·
> [...] whereas OOP approach is open for extension, with the associated boilerplate in the visitor logic. Yes, by default. But doesn't eg Java let you mark cl
by eru 1y ago
> [...] whereas OOP approach is open for extension, with the associated boilerplate in the visitor logic.
Yes, by default. But doesn't eg Java let you mark classes as final or something like that?
> In languages of ML linage, we can combine both approaches with a mix of sum types and functors/type classes.
I think Rust allows something similar, but I'm not sure whether you'd call it 'ML linage'?
- pjmlp 1y agoYes, you can mark classes final as closed for extension, however Java follows the wisdom at the time that by default classes are open for extension. Additionally, modern Java has sum types modeled on the same way as Scala. Rust is to some extent inspired by ML languages, hence why several OCaml and Haskell refugees also hang around Rust.