From: Paul Brannan Date: 2002-04-23T04:52:36+09:00 Subject: Re: Ruby as Smalltalk On Tue, Apr 23, 2002 at 03:33:43AM +0900, Avi Bryant wrote: > In theory. In practice, Ruby's syntax makes this awkward enough that > you essentially never do it. Survey: how many people have *ever* > written a method that takes two procs? I have done this: def exception_intercept(main_block, rescue_block) exc = true begin main_block.call(exc) exc = false ensure begin rescue_block.call($!) if exc and not $!.nil? rescue KillException end end end def kill_exception raise KillException end class KillException < Exception end but the syntax for using it is ugly: exception_intercept( proc { raise MyException }, proc { |exc| case exc when MyException puts "Got the exception!" kill_exception # don't let this exception propogate further else puts "UH OH!" end } ) > As for "Ruby as Smalltalk" in general, I'd say the main thing it's > missing is not the "hoopy control structures", although those would be > very nice to have. What I'd like is the Smalltalk environment, where > everything in the system (from the compiler to the stack frames) is > reified as an object, where modifying code on the fly is the normal > (or only) mode of development, and where all the tools are written to > take advantage of this. Oh, and I'd like become(). Of course, this Can you give an example where become() would be useful? > would just be smalltalk with funny syntax and mixins, but hey, such a > tool could go a long way. Paul