Interesting, Scott, however, I don't see what would stop apporachBlue script if nothing is in the Yes "fork."
Also, my experience with recursion was basically from my work with Logo, where I had to call a procedure (within itself) for that procedure to be recursive. Since a ticking Squeak script keeps calling itself why was it even necessary for you to add the "do approachBlue" (recursive call) to your version of the script?
Phil
On Mar 28, 2005, at 2:15 AM, Scott Wallace wrote:
Hi, all. A question arose recently on the Squeak-dev mailing list (a list mostly inhabited by software engineers) concerning "recursion in etoys." I wrote a reply, which I'm herewith forwarding to the Squeakland list, on the chance that this information might be useful to some readers. BTW my reply was suppressed by the moderators of the Squeak-dev list, who said it was too large, so it never did actually appear on that list ;-)
-- Scott
Hi, Kevin,
Yes, etoys do support recursion. But they don't have a good way of detecting and recovering from *runaway* recursion, which is what was befalling your script.
Here's a recursive etoy script which does what you want, and which *does* converge, provided that there is a patch of the appropriate blue somewhere ahead of the Star:
<image.tiff> Two points to note here:
(1) The critical difference between this and what you did is that after the *copy* is made, this script "includes" that copy in the container. Without the "include," the copy isn't present in the "world", so neither it nor any future generation of "copy" will be "over blue" and hence terminate the recursion. That's why your recursion ran away.
(2) In the last line, it's *okay* simply to have "Star's nextGuy approachBlue". The value of the "do" inserted here is that this defers the recursive #approachBlue script call until the next cycle of the simulation. The result will be there will be a sense of "movement" since each generation will be born on a different tick, whereas without the "do" all the generations will be born within the same "tick" so all will appear instantaneously -- a much less nice effect.
Cheers,
Scott
PS: Please check out Squeakland.org, and you may well want to subscribe to the Squeakland mailing list: http://www.squeakland.org/mailman/listinfo/squeakland
At 10:08 AM -0800 3/25/05, Kevin Lawrence wrote: Is it appropriate to post questions about etoys to this list ?
[I'll risk it this time - let me know if there is somewhere else I should be asking, thanks.]
I tried making a simple etoys script with recursion and it hangs as soon as I click the run icon.
the script was essentially (excuse my Java-ish pseudocode) ...
spawn script test self.sees blue
yes
no self.newCopy = self.copy self.newCopy.forwardBy self.length self.newCopy.spawn
Assuming I haven't made a really silly *mistake, should this work ?
Is recursion supported ?
(I searched the bug database but couldn't find anything)
Thanks !
Kevin
- Please tell me if there is a silly mistake !
<P5E04C520>_______________________________________________ Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland