On Thu, 22 Dec 2005 14:07:03 -0000, jwesley <justin.w.smith / gmail.com> wrote: > I disagree that this particular use of an exception would be a no-no in > Java. Inability to parse input is justifiably an "exceptional" case. > And the handling of that exceptional case is also appropriate. > Agreed, I was referring more to the idea of swapping out flow control for exceptions in general. Obviously if the input is an exceptional case, throw an exception. I have just been wondering about a few examples of this I've seen in Ruby code, and just picked this as an 'in' to ask about it ;) > The big "no-no" about exception usage is true for any language: "Don't > use exceptions for flow control". > > The following code is "wrong" for various reasons as well as violating > the "axiom" above: > > begin > # display 1 through 10 > i = 0 > while true > unless i > 10 > puts i > else > raise "End o' the line" > end > i += 1 > end > rescue > end > > Ruby provides enough mechanisms for "controlling the flow" that using > exceptions for "normal" conditions is definitely poor style, if not > worse. > Okay, good. That was my feeling too. > BTW "continuations" (related to exceptions) are a fairly powerful tool > to handle the times when strange flow control might be needed. > I can't wait to find something I can try continuations out on, though I remember reading somewhere that they too are slow, so one to keep for those strange cases as you say? Cheers, -- Ross Bamford - rosco / roscopeco.remove.co.uk