The only addition here, IMHO, is that any input, whether it be arguments or
reading from a pipe, falls in this category.
| filename = attempt(sys.argv, IndexError)
| if isbomb(filename):
| print 'usage: cat filename'
So how does this differ from:
try: filename = sys.argv
print 'usage: cat filename'
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. :-) :-)