3 ms·
> Sorting out what was returned requires a "match" statement, which is rather verbose. It's an elegant way to avoid null pointers and error codes, but it's quit
by adamnemecek 12y ago
> Sorting out what was returned requires a "match" statement, which is rather verbose. It's an elegant way to avoid null pointers and error codes, but it's quite verbose in practice.
I'd be surprised if you hadn't thought of this but have you thought about wrapping up the error handling logic in some macros?
- Animats 12y agoYes, there's a workaround, but that's not the point. So many layers of cruft in the early days of a language is worrisome. It took C++ two decades to dig itself into a hole this deep. Is this the price of not having exceptions?
- ecnahc515 12y agoNo, this is the price of choosing to make it impossible to not explicitly check an error, even if your going to ignore any potential error, at least you know it's impossible to accidentally write code which blindly forgets about the potential error cases.
- pcwalton 12y agoI disagree that it's cruft; to me null pointers feel like cruft, because they silently blow up when you dereference them. The code above handles the None case explicitly, which is what any systems code should be doing.
- adamnemecek 12y ago> Is this the price of not having exceptions? I guess this is a matter of opinion but are you familiar with the school of thought (to which I belong) that claims that exceptions are worse than goto's? (And before anyone comes in to say that goto's are okay, I'm well aware that they make a lot of sense for certain things and I do use them for those things but they should not be the main flow control operation).
- Animats 12y agoXKCD on gotos: http://xkcd.com/292/ http://xkcd.com/292/