3 ms·
Another valid and mysteriously killed post. When are the admins going to do something about this? ---- in [1], tomp [2] posted: That's one way to look at it,
by pygy_ 15y ago
Another valid and mysteriously killed post. When are the admins going to do something about this?
----
in [1], tomp [2] posted:
That's one way to look at it, and it certainly is valid, to some extent.
Another way to look at it is that exceptions are fundamentally limited, and conditions provide a whole new sea of possibilities.
His example is rather awkward and actually confuses the reader, rather than excites. The point of conditions actually is to allow flexibility without all the if statements and delegates. His final getVal() function should look like this Object getVal() { try { if (val == null) throw new NoValException(); else return val; } catch (UseValRestart r) { return r.getVal(); } } and the high-level code should handle how the value is provided (either some specific value, user input, web request, random bits, etc...). So, one only has to write the code for getVal() once and can customize it indefinitely.
----
[1] http://news.ycombinator.com/item?id=2683678 http://news.ycombinator.com/item?id=2683678
[2] http://news.ycombinator.com/user?id=tomp http://news.ycombinator.com/user?id=tomp
- Total_Meltdown 15y agoI understand what the intent is, and I think it could be a useful mechanism, but as I've said in other posts, I disagree that exceptions are the way to go about it. I think something similar to exceptions, but intended for this kind of indirection would be good. But I'm strongly of the opinion that all exceptions should be treated as problems to be fixed, not just another pattern.