[plt-scheme] Question on the teachpack world.ss

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jan 11 12:04:24 EST 2008

On Jan 11, 2008, at 9:34 AM, Jean-Paul ROY wrote:

> Can you explain me why this code stops, prints "End" at the  
> toplevel, but not the text "Over !" in the canvas ?
> Everything else fine.
> Thanks (DrScheme v371, MacOS-X 10.5) :
>
> (define (next world)
>   (if (crashed? world)             ; ok
>     (begin (place-image (text "Over !" 48 "blue") 100 100 (empty- 
> scene WIDTH HEIGHT)) ; nothing happens !
>            (end-of-time "End"))    ; ok
>     (new-world ...)))              ; ok
>
> (on-tick-event next)


place-image, as documented (and, I assume, used properly in the rest  
of your program), produces (returns) a new image. It has *no* effect  
whatsoever. It is designed to work with Beginner (see below) already,  
where effects aren't available. So here

  (begin (place-image ....) ;; produce image, then throw it away
         (end-of-time ...)) ;; end of time


> By the way, it is a bit annoying to be limited to "advanced  
> student" to run this teachpack, why not full Scheme ?

(require (lib "world.ss" "htdp")) works in ALL languages, including  
Beginner, Advanced, Module, etc.

-- Matthias



Posted on the users mailing list.