Quote:
>Is there a more elegant way in Smalltalk to break an infinite loop
>(for example a whileTrue condition that sometimes never realize) than
>using a counter and a return when this counter is too high?
I guess you have the following code structure in mind?
[ true <i.e. no break condition> ]
whileTrue: [ <code>
<break condition>
ifTrue: [ ^<return value or nil>].
<more code>
].
If that is the case, here is a "better" way of doing it, without resorting
to anything esoteric.
[ <code>
<break condition> ]
whileTrue: [ <more code>].
I am sure you will agree that the second form is much more readable.
Didier