[Squeak-fr] Relecture document sur la syntaxe Smalltalk

stéphane ducasse ducasse at iam.unibe.ch
Dim 19 Fév 09:08:17 UTC 2006


en VisualWorks

	ils ont la definition suivante




whileTrue: aBlock
	"Evaluate the argument, aBlock, as long as the value
	of the receiver is true."

	^self value
		ifTrue:
			[aBlock value.
			[self value] whileTrue: [aBlock value]]

	"This method is inlined if both the receiver and the argument are  
literal
	blocks. In all other cases, the code above is run. Note that the code
	above is defined recursively. However, to avoid actually building an
	activation record each time this method is invoked recursively, we have
	used the '[...] whileTrue: [..]' form in the last line, rather than  
the more
	concise 'self whileTrue: aBlock'. Using literal blocks for both the  
receiver
	and the argument allows the compiler to inline #whileTrue:, which  
(in the
	absence of type inferencing) could not be done if we were to use
	'self whileTrue: aBlock'."


More information about the Squeak-fr mailing list