[plt-scheme] current-directory and eventspaces

From: Jefferson Provost (jp at cs.utexas.edu)
Date: Mon Dec 16 18:13:17 EST 2002

I'm having some trouble understanding how changing the current directory 
interacts with different eventspaces.

The example below creates a specialized frame which changes the current 
directory upon instantiation.  If the new frame is created in a new 
eventspace, the current directory change doesn't seem to "take". 
However, if the object changes the current directory again, after 
instantiation, then it works.

Without the new eventspace, everything seems to work normally.  I don't 
get it...



(define dir-tester%
   (class frame%

     ; internal directory field
     (init-field dir)

     (super-instantiate ())

     (instantiate button% ()
       (parent this)
       (label "Print dir")
        (lambda (b e)
          (printf "dir = ~S~% (current-directory) = ~S~%"
                  dir (current-directory)))))

     (instantiate button% ()
       (parent this)
       (label "Select dir")
        (lambda (b e)
          (set! dir (get-directory))
          ; set the current directory here after selection
          (current-directory dir))))

     ; set the current directory here on initialization
     (printf "Supposedly setting current-directory to ~S~%" dir)
     (current-directory dir)
     (printf "current-directory is supposedly now ~S~%"

; Comment out next line to see correct behavior
(current-eventspace (make-eventspace))

(define tester1
   (instantiate dir-tester% ()
     (label "Dir Tester 1")
     (dir "/tmp")))

(send tester1 show #t)

Posted on the users mailing list.