[plt-scheme] I miss end-of-time...

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Fri Mar 12 11:59:42 EST 2010

On Fri, Mar 12, 2010 at 11:45 AM, Stephen Bloch <bloch at adelphi.edu> wrote:
> On Mar 11, 2010, at 3:16 PM, Carl Eastlund wrote:
>> ...and the alternate form of stop-when alleviates that problem by
>> providing an alternate renderer, which can display something like "End
>> of Game".
> Yes, but you still need to insert a special "quitting" value into your model so the key handler
> can signal the stop handler that it should stop.  I claim that that approach is more confusing
> than having the key handler say DIRECTLY "stop the animation now", and keeping to the
> obvious, natural model (in this case the radius).

It doesn't say it directly; functions say things directly by returning
values.  "end-of-time" says it very indirectly; I forget if it fails
to return, and uses a continuation to jump out of the big-bang loop,
or if it uses a mutable channel to grab the latest world value and
return that, but in any event, in the context of HtDP and functional
programming I wouldn't call either of those "direct".

Furthermore, I don't consider a natural number to be a natural model
for your program; it's merely a convenient shortcut.  You have an
entire game state -- stop on key press -- that isn't represented at
all.  If you're concerned about keeping your function inputs simple,
bear in mind that the event handlers plus "live" world renderer only
ever input a "live" world (i.e. a natural number) and the "dead"
renderer only ever inputs a "dead" world (false).

Certainly, it can be more convenient to use end-of-time, and I can't
argue for what will or won't be "confusing" for your students, you may
know that better than I do.  On the other hand, in giving up
functional programming, you give up a lot of the HtDP approach.  How
do you test a function that uses end-of-time?


Posted on the users mailing list.