From: Jean-Hugues ROBERT Date: 2002-04-23T17:18:56+09:00 Subject: Re: Ruby as Smalltalk Hello, At 15:56 23/04/2002 +0900, you wrote: >By RCR#90, it would be: > > exception_intercept({|| raise MyException}, > {|exc| > case exc > when MyException > puts "Got the exception!" > kill_exception # don't let this exception propogate further > else > puts "UH OH!" > end > } > ) > >But I'm still not sure it's good enough. > > matz. Parenthesis are already not mandatory: obj.meth { # first block },{ # second block } Is the "," really necessary or could "} {" be considered equivalent to "},{" ? With do/end: obj.meth do # first block end do # second block end In a language I designed, in a method call, the name of the method could be expressed in multiple fragments: def PrintOn( msg, media) end o.PrintOn( "Classical", media) o.PrintOn "No parenthesis", media o.Print: "Smalltalk style" On: media # 2 fragments here Of course weird things were possible to: o.Pr: "Hello" intOn: "World" At the end there were so many ways of forming the name of a method that is was becoming hard to figure out what was the method called. I then decided to mostly use the classical form and use the "Smalltalk" style in rare occasions where indentation make it clear about what was happening (i.e. human readable. it was always clear enough for the compiler). But the lf termination in Ruby will clash here. This worked with "named values" (hash) too: o.Print: :Color => Red, Text: "Hello" On: media o.Print: (Color: Red, Text: "Hello") On: media # Parenthesis needed o.Print: (Color: Red, Text: "Hello") On: media BTW: def printon end ; o.print: xx on: yy; for those that don't like CamelCase. BTW: I also had a "with xx do xxx end" where any ".mm" inside the "with" would resolve into xx.mm. I think other languages have such a "with" statement. This is another story I guess Yours, Jean-Hugues --------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17