On 5/10/07, Giles Bowkett <gilesb / gmail.com> wrote:

> Smalltalk is the purest OOP language there is and it doesn't **have**
> if or unless at all. You know how you can bypass control structures in
> Ruby by using blocks and closures instead? In Smalltalk, that's the
> only way to do control structures at all. "If" and "unless" don't even
> exist in Smalltalk.

Not entirely true.

Yes, in Smalltalk control structures are built using methods on
Booleans and Blocks, and with Block arguments.

On the other hand, most Smalltalk implementations cheat on this.
There's an old VM implementors mantra that you have to cheat so you
have to work hard not to get caught cheating.  In practice if:else:
gets compiled down to test and branch bytecodes, with exception
processing to handle the rare case where the receiver isn't a boolean.
 Evaluating a block in Smalltalk looks like a message send but in
reality it's usually implemented as optimized byte code sequences
after some analysis.  This led to some mystifying code reading.  The
old Digitalk Smalltalk had the value method in Block which read

   value
       ^self value

Which sure looks like it should be an infinite loop.  In reality, this
code never got executed except when someone did something silly like:

     [1 + 2] perform:#value

or maybe less silly by doing this with a stored block.

In this regard, the purest OO language when it comes to control
structures is probably Self, which avoided such hand-crafted
optimizations in favor of dyamically optimized code.


-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/