Smalltalk has the whileTrue:-Message implemented through recursion (in VisualWorks) or through compiler-inlining (in Squeak/Pharo). Is there a way to define such a method without using one of them? If not, is there a proof for that avaiable somewhere?
Smalltalk has the whileTrue:-Message implemented through recursion (in VisualWorks) or through compiler-inlining (in Squeak/Pharo).
Share
whileTrue: & whileFalse: always return nil.
e.g. if there is a normal recursive definition:
the ifTrue: will return nil if self value is false and so the value should always be nil. That’s reflected in the compiler’s optimization. The original blue book Smalltalk-80 V2 definition is
So just change your’s to
or??
But alas both of these crash the VM sometime after the second iteration because thisContext pc doesn’t answer the pc on the next iteration, but instead whatever the top of stack is 🙂
However the following does work: