The only addition here, IMHO, is that any input, whether it be arguments or
reading from a pipe, falls in this category.
| Example:
|
| filename = attempt(sys.argv[1], IndexError)
| if isbomb(filename):
| print 'usage: cat filename'
| sys.exit(2)
So how does this differ from:
try: filename = sys.argv[1]
except IndexError:
print 'usage: cat filename'
sys.exit(2)
In other words, what am I missing here?
| This doen't mean that I don't like the try...except...else... idea; in
| fact I like that as well (and it's easier to implement :-), but the
| letter bomb idea may have a different application area. Note that if
| the first argument of attempt() is a bomb, it is returned unchanged,
| so it is possible to make nested attempts.
I guess I fail to see the actual application area for letter bombs. The only
difference is the paradigm, it doesn't seem to solve anything that can't be
solved with try:except:[else:] in as many lines. How would nested attempt()s
work? I.e. if *any* object in the expression is a bomb, that bomb would be
returned? I feel like I'm missing the point...
| Regarding Jaap's idea of restarting operations: I'm afraid this is
| totally unrealistic, and only rarely can exceptional situations be
| mended in a useful way anyway.
What about timer exceptions (continue)? Or what about one time
initialization that is context sensitive (restart)? You could give the
raiser of the exception the ability to specify whether this operation can be
restarted and/or continued.
| In any case it
| would require a complete overhaul of all the implementation aspects of
| exceptions, which isn't likely to happen (well, maybe when Doug Moen
| gets around to implementing Python++ :-).
Well, I was afraid of that. :-) :-)
-Jaap-