[ruby-talk:00898] Re: Contrast Ruby and Other Languages

From: Clemens Hintze <c.hintze@...>
Date: 1999-11-02 05:29:59 UTC
List: ruby-talk #898
GOTO Kentaro writes:
> Hi, 
> 
> In message "[ruby-talk:00895] Re: Contrast Ruby and Other Languages"
>     on 99/11/01, Clemens Hintze <clemens.hintze@alcatel.de> writes:
> 
> >- Ruby is an complete OOL. That mean all in Ruby is an object. Not in
> >  the sense of Python or Perl. But in the sense of Smalltalk. The
>                                                     =========
> 
> This may confuse some people because *all* in Smalltalk is an object,
> even controls.  Indeed, one of my friends mistook in this point; He
> believed that even a control in Ruby are an object after he had heard
> Matz's talk (I've corrected his misunderstanding, then he looks being
> disappointed little). 

I can understand him... But he, like me before, does a simple error...

All is *an* object, does not necessarily mean, that control structures
also have to be an object, IMHO. It only means to me, that all you can
graps or use (like: "hello", 1, proc{print"world"}) is an object. But
matz has decided, that blocks are not things you can grasp (yield
doesn't count here). Perhaps he has performance reasons? But you can
convert such a block to a Proc instance, so that it would be
graspable (nice word, isn't it? ;-)

Ruby could do it like Smalltalk, but then in that case Smalltalk's
syntax would be more appropiate, there.

I think,

    class Proc
       def ifThenElse(th,el)
	  if self.call
	     th.call
	  else 
	     el.call
	  end
       end
    end
    
    a = 5

    (proc{a==5}).ifThenElse(
       proc{print"Gotcha"},
       proc{print"Missed"}
    )

is possible, but looks, ahem, ugly?!?

After I was convinced to think this way, I could live with Ruby's
approach. I also would find it better, if Ruby behaves more like
Smalltalk here, but then ... Ruby is Ruby ;-)

> 
> -- gotoken
> 

\cle

-- 
Clemens Hintze  mailto: c.hintze@gmx.net

In This Thread