ALU capability (was Re: [E-Lang] Authority -- what is its dual?)

Andreas Raab Andreas.Raab@gmx.de
Fri, 19 Oct 2001 14:13:00 -0700


Hi Peter,

[Smalltalk blocks being objects]
> This is just veneer.  A lexically-scoped closure is a very
> different beast from a standard class-defined object -- it
> requires specific mechanisms in the virtual machine to
> implement it.

Only for block activation (e.g., the invokation through the message value).
All blocks in Smalltalk are instances of a common class (usually called
BlockClosure) and what you get when you "write" a block in your code is
nothing but another literal. E.g., if you write "5" in your code you get the
literal integer 5, if you write "[3+4]" you get a literal block [3+4].

It might be enlightening to look at a concrete example (forgive me if you
know this). A control structure like if-then-else is really implemented by
selectively evaluating blocks. For if-then-else you'd write something like

	condition
		ifTrue:[self doSomething]
		ifFalse:[self doSomethingElse]

The message "ifTrue:ifFalse:" is then implemented for the two boolean
receivers true and false (which are instances of class True and False
respectively) simply by:

True>>ifTrue: trueBlock ifFalse: falseBlock
	trueBlock value.

False>>ifTrue: trueBlock ifFalse: falseBlock
	falseBlock value.

Thus, besides block activation there's no special support in the virtual
machine.

> If you want the phrase 'Blocks are Objects' to mean
> something, then you must define precisely what you mean
> by 'Object'!

At this point, most discussions drift off in the meta-verse ;-) I usually
prefer the (widely accepted) definition that "an Object is a thing you can
send messages to". Since you can send messages to blocks, I'd say they
certainly qualify :-)

Cheers,
  - Andreas