Silly Question about Blocks and whileTrue:

Raab, Andreas Andreas.Raab at disney.com
Thu Feb 8 05:19:44 UTC 2001


PS to my last message:
> Why does whileTrue: return anything?

It's to keep the compiler semantics (the code compiled for #whileTrue: is
not a message but inline code) equivalent to the result when the code is run
by using, e.g., 
	[index < 100]
		perform: #whileTrue:
		with: [index := index + 1].
If you'd take out the return from #whileTrue: the result of the above would
be different from evaluating '[index < 100] whileTrue:[index := index + 1]'.
Of course there is a question if both variants couldn't either return the
receiver block, the argument block or the result of the last evaluation of
either receiver or argument block. All of them are possible and why exactly
this semantics has been chosen is a question I can't answer.

Cheers,
  - Andreas





More information about the Squeak-dev mailing list