[Squeak-fr] Relecture document sur la syntaxe Smalltalk

stéphane ducasse ducasse at iam.unibe.ch
Dim 19 Fév 11:29:49 UTC 2006


Exact
Je pense (mais c'est une hypothese) qu'en sqeuak le code n'est jamais  
execute.
J'ai demande dans la mailing-list.
Il faudrait que je regarde le compilation mais je n'ai pas le temps  
de vraiment plonger dedans

Stef
On 19 févr. 06, at 11:27, Loïs Lherbier wrote:

> Merci bien.
> Je trouve le commentaire qui explique comment le compilateur  
> optimise le
> code trés intérressant (et cela explique aussi le commentaire dans le
> code de Squeak). Moi qui trouvait justement que la définition  
> récursive
> du whileTrue était un peu barbare :)
> Mais cela ne m'explique toujours pas l'implémentation du whileTrue  
> dans
> Squeak ?
>
>  Loïs
>
>
> Le dimanche 19 février 2006 à 10:08 +0100, stéphane ducasse a écrit :
>> 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'."
>> _______________________________________________
>> Squeak-fr mailing list
>> Squeak-fr at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/squeak-fr
>
> _______________________________________________
> Squeak-fr mailing list
> Squeak-fr at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/squeak-fr



More information about the Squeak-fr mailing list