[comp.lang.smalltalk] A strange Context method in Smalltalk/V

peter@celia.UUCP (Peter Farson) (08/15/89)

The other day, while browsing through the classes (Smalltalk/V Mac), I
noticed a strange method in class Context.  The source looked like this:


value
	"Answer the result of evaluating the no argument block
	described by the receiver."
	self checkArgument: 0.
	^ self value


Now this seems very odd to me.  It looked like an endless recursive loop
to me, so I stuck a "self error: 'say something'" in it, and then tried
sending this message to a block.  No debug windows popped up.  Only when
I tried "[block] perform: #value" did it seem to actually execute the
modified method.  The only thing I can figure out is that the Smalltalk
compiler treats some source code expressions as special cases, producing
byte-codes that are optimized but that end up not invoking the method that
it by definition should.  The methods for "value:" and "value:value:" are
similar.

Does anyone know what's really going on here?  If the compiler has exceptions
to the rule, how many and what are they?  If anyone knows something about
this, I would very much like to hear from them.


-- 
Can a bee be said to be                Peter Farson
An entire bee if                       celia!peter@tis.llnl.gov
Half the bee is not a bee              ...{ihnp4,ames}!lll-tis!celia!peter
Due to some ancient injury?