in reply to Re^4: chaining method calls (perl/DWIM)
in thread chaining method calls
How often have you written code like
the above? If you do, then, yes, you write bizarre enough code that my DWIM design will likely not do what you mean.$ref = { foo => open( BAR, "> baz" ), bar => print( BAR "biff\n" ), };
This part of the design is only for methods that don't return interesting values, merely success/failure notification (though in the form of an object to enable chaining of methods). So if you are in the habit of squirreling away uninteresting values in long-lived locations that you never check, then, yes, you won't know about failures until global destruction. But then, if you do that and don't have my error object, then you won't know about failures period, so I fail to see the problem. Yes, if I always threw exceptions you could argue that one would know about failures no matter what, but I think you'd find many people would just get very sloppy about catching and ignoring way too many exceptions and you really wouldn't be in that much of a better position.
I can see some value in "all failures are exceptions", but I really do think it goes too far. Sometimes the failure cases are the reason for the flow and so should be handled as part of the flow, not forced into some exception catcher. Why just this week I was forced to catch some exceptions that really should have been normal failures and it was much more painful that way.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: chaining method calls (perl/DWIM)
by adrianh (Chancellor) on Jun 20, 2003 at 16:36 UTC | |
by tye (Sage) on Jun 20, 2003 at 17:21 UTC |