|
 |
Darren New <dne### [at] san rr com> wrote:
> And in Smalltalk, conditional branches are also method calls. You send two
> "blocks" to a boolean, and it executes the appropriate one. E.g., you call
> (x == 5) ifTrue: [y print] ifFalse: [z print]
> So (x == 5) sends the == message to x with the argument 5, and that returns
> either true or false. The methos "ifTrue:ifFalse:" in "true" evaluates and
> returns the first argument. The method of the name in "false" evaluates and
> returns the second argument. So, technically, you don't need conditionals
> either, just deferred evaluation (aka lambda expressions).
Could a simple conditional be more awkward than that?
(I can only imagine how hard it is for compilers to optimize that into a
regular machine code conditional construct.)
--
- Warp
Post a reply to this message
|
 |