From: Robert Dober Date: 2009-02-01T03:57:08+09:00 Subject: Re: replacing callcc by catch/throw On Sat, Jan 31, 2009 at 9:25 AM, Thomas Hafner wrote: > Tanaka Akira wrote/schrieb <87d4e56tai.fsf@fsij.org>: > >> The argument of catch is optional in Ruby 1.9. >> [...] >> catch generates a unique tag if not given. > > Fine! I like that much more than it is in Ruby 1.8. Imagine a Ruby > program uses code from different libraries from different people. In > Ruby 1.8 there's the danger that the catch/throw pairs do interfer in > a bad way as in my example, and because the tags are not part of the > interface, nobody sees the danger. For that reason the new way of > catch/throw should preferred to the old way whenever possible. Bad design IMHO catch/throw can be used perfectly save as follows class MyClass def thrown; @thrown ||= Object::new end def do_throw; throw( @thrown, 42) end def with_throw; catch( @thrown )do yield end end end But it is still a good use case for Charley's idea !! Cheers Robert -- It is change, continuing change, inevitable change, that is the dominant factor in society today. No sensible decision can be made any longer without taking into account not only the world as it is, but the world as it will be ... ~ Isaac Asimov