4 ms·
> - Nonzero-exit modeled as exceptions. (I think elvish is doing this, but I haven't reviewed the code in detail.) No really. I have not yet decided how error/
by xiaq 12y ago
> - Nonzero-exit modeled as exceptions. (I think elvish is doing this, but I haven't reviewed the code in detail.)
No really. I have not yet decided how error/exception (http://www.haskell.org/haskellwiki/Error_vs._Exception http://www.haskell.org/haskellwiki/Error_vs._Exception) handling should work.
I actually like how golang does it - errors with panic/recover, exceptions with return values. But I have not been able to make a decision yet - the situation is a bit more complex than golang. As a result there is no if/else builtin yet, let alone raise and try/except (or panic and recover).
- comex 12y agoFor the record, I am personally usually a fan of making exceptional conditions return values (though I prefer Rust's explicit unwrapping to Go's approach), since in most programs it's good to think at least somewhat carefully about error handling anyway. However, in one-liners, there is no need for proper error handling, and the vast majority of exceptional conditions (e.g. file not found) are caused by mistakes that should be rectified by changing the code. Therefore, in a language that prioritizes one-liners, as I believe any shell should, I believe the traditional exception approach is the best.