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

From: John Clements (clements at brinckerhoff.org)
Date: Thu Mar 11 14:57:47 EST 2010

On Mar 11, 2010, at 11:34 AM, Stephen Bloch wrote:

> In recent versions of the world/universe teachpacks, the "end-of-time" function has been removed.  This makes some animations considerably harder or more unnatural to write.
> 
> Try this: write an animation of a disk whose radius starts at 0 and grows by 1 pixel per second.  The animation stops when the user presses any key on the keyboard.
> 
> You could do this with a struct that contains a "quitting?" field, but my students won't see structs for several more weeks. So the model has to be just a number.  Now how could the key handler indicate, with a number, that the animation should stop?
> 
> Well, we could use a negative number, since it'll never go negative in the normal course of events... but since the draw handler is called after the tick/mouse/key handlers but before the stop-when handler, that means we're going to call a function that draws a disk of specified radius with a negative number, and it'll crash.  We could write the draw handler to check whether the number is negative before trying to draw a disk of that radius, but (a) that adds unnecessary complexity, and (b) my students won't see conditionals for another week and a half.
> 
> Alternatively, we could use a really large number, and just hope nobody runs the animation for long enough that the radius gets up to that point in the normal course of events.  And it has to be a small enough number that a disk of that size COULD be drawn, or the draw handler will crash again as above.
> 
> Or I guess we could use a fraction.  Which feels really weird and unnatural, and relies on the fact that the "circle" function rounds when you give it a fractional radius.

Yikes! Those all sound like exactly the kind of thing we're trying to *prevent*!

> With an "end-of-time" function, it's trivial: the key handler ignores its parameters and calls "end-of-time".

I think the conclusion here is that imperative interfaces allow hiding of state, and make certain programs appear much simpler; it sounds like you just need to wait on writing that program until you've got structures. No?

John Clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100311/3a3ff851/attachment.p7s>

Posted on the users mailing list.