3 ms·
The problem with options in non-ML languages is that invalid state is unrepresentable[1]. E.g, in Java Option<Integer> can either be null, empty, some with null
by ivanjermakov 2y ago
The problem with options in non-ML languages is that invalid state is unrepresentable[1]. E.g, in Java Option<Integer> can either be null, empty, some with null and some with a number.
To solve this problem, a language have to disallow null/nil as a bottom type and provide nice syntax to initialize types with optional types.
[1]: https://geeklaunch.io/blog/make-invalid-states-unrepresentable/ https://geeklaunch.io/blog/make-invalid-states-unrepresentab...
- mmaniac 2y agoOptional types don't fix this. The problem here is not having default (or named) function arguments. With optionals, you still have to pass every arg explicitly. Languages with both of these features like Python don't end up using the builder pattern or reinventing it like this author.