Re:Revenge of the Types
by the_af on Monday August 25, 2014 @01:19PM
(#8222729)
If when the type of a function F is "Foo or Null", you can express it as something like
F(...): Foo?
and if you're later forced to deal with such a value, Null cannot catch you by surprise, then haven't you just rediscovered Option types?
If, on the other hand, "?" is just an operator you use on values that can be null, to guard against an exception, this seems less useful. Are you going to wrap every return value of every function call with it? What happens if you forget? How can you know, at a glance, if a function may return a null value?
F(...): Foo?
and if you're later forced to deal with such a value, Null cannot catch you by surprise, then haven't you just rediscovered Option types?
If, on the other hand, "?" is just an operator you use on values that can be null, to guard against an exception, this seems less useful. Are you going to wrap every return value of every function call with it? What happens if you forget? How can you know, at a glance, if a function may return a null value?