[plt-scheme] I miss end-of-time...
My student now mainly uses exit because it presents a convenient way to
close the World and State windows together. I suppose we're looking for a
stop-when that will close the windows rather than draw one last scene.
Maybe the last-picture argument could produce (union Scene false), with
false indicating that the world's window(s) should close. That's only a
very low priority request.
Paul
-----Original Message-----
From: Matthias Felleisen [mailto:matthias at ccs.neu.edu]
Sent: Thursday, March 11, 2010 4:07 PM
To: engineer at alum.mit.edu
Cc: 'PLT-Scheme Mailing List'
Subject: Re: [plt-scheme] I miss end-of-time...
Paul,
-- cmd-k is the drscheme emergency key for killing the current
evaluation _and_ the entire evaluator
-- one could bind "k" in every animation like this:
(require 2htdp/universe)
(require 2htdp/image)
(big-bang 0
(on-tick add1)
(on-draw (lambda (n) (text (if (boolean? n) " " (number-
>string n)) 11 'red)))
(stop-when boolean?)
(on-key (lambda (n key)
(if (key=? key "k") false n))))
and then nothing bad would happen.
On Mar 11, 2010, at 3:05 PM, <engineer at alum.mit.edu> wrote:
> One of my students has the habit of tying his "k" key to (exit). It
> gives
> him a quick non-mousy way to close his world and state windows
> simultaneously. I just tried it. It works but leaves Dr. Scheme in
> a weird
> state. The Definitions window works and is immediately runnable and/
> or
> editable, but the Interactions window is disabled. I wouldn't like
> the
> Interactions window being disabled all the time, and I don't know
> what other
> ramifications there may be to ending a World by (exit)-ing. But it
> serves
> my student's purposes.
>
> -Paul
>
> -----Original Message-----
> From: plt-scheme-bounces at list.cs.brown.edu
> [mailto:plt-scheme-bounces at list.cs.brown.edu] On Behalf Of Stephen
> Bloch
> Sent: Thursday, March 11, 2010 2:34 PM
> To: PLT-Scheme Mailing List
> Subject: [plt-scheme] I miss end-of-time...
>
> 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.
>
> With an "end-of-time" function, it's trivial: the key handler
> ignores its
> parameters and calls "end-of-time".
>
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme