3 ms·
Would this not just return nil for the else case? This is already the behaviour of Ruby and Lua as well, of course both are unityped languages where "just retur
by haileys 4y ago
Would this not just return nil for the else case? This is already the behaviour of Ruby and Lua as well, of course both are unityped languages where "just return nil" semantics are the natural conclusion.
The OP however is discussing how this kind of thing would work in a language with a richer type system, like Rust.
- SeanLuke 4y agoI guess the Lisp example is an example of a nullable type, which he's railing against; he'd rather have prewrapped types like Some(result) vs None. But it's still an optional expression, and I'm not convinced that declaring an optional type, doing the expression(s), then unwrapping and checking the result for None, is any better than just using an exception handler. He insists that nullable types force you to check for null, but they don't, at least in his math example here. Just let the runtime do it and throw an exception.
- f_devd 4y ago> Just let the runtime do it and throw an exception. Afaik there are no exceptions in rust only panics & `Result`s (and `Option` I suppose)
- eyelidlessness 4y agoIt will typically return nil, but it’s worth noting that in some lisps nil is the same as the empty list (). Not quite the same as Option/None, but conceptually more similar than most other languages’ null types.