[plt-scheme] Interacting w/ MzScheme

From: Daniel Pinto de Mello e Silva (daniel.silva at gmail.com)
Date: Fri Dec 10 14:22:55 EST 2004

On Fri, 10 Dec 2004 12:48:28 -0600, Pinku Surana <suranap at gmail.com> wrote:
> What magic incantation will erase MzScheme's state without
> restarting? DrScheme somehow does this.

I'm not sure if this is how DrScheme does it, but try this:

$ cat bah.ss
(module bah mzscheme
  (printf "bah!~n"))
$ mzscheme
Welcome to MzScheme version 299.22, Copyright (c) 2004 PLT Scheme, Inc.
> (define ns1 (make-namespace 'initial))
> (define ns2 (make-namespace 'initial))
> (eval '(require "bah.ss") ns1)
bah!
> (eval '(require "bah.ss") ns1)
> (eval '(require "bah.ss") ns2)
bah!

So...

$ mzscheme
Welcome to MzScheme version 299.22, Copyright (c) 2004 PLT Scheme, Inc.
> (define (repl)
   (printf "~n>> ")
   (print (eval (read)))
   (repl))
> (define (toplevel)
   (let/ec ec
     (parameterize ([current-namespace (make-namespace 'initial)])
       (namespace-set-variable-value! 'exit (lambda () (ec #f)))
       (repl))))
> (toplevel)
>> 8
8
>> 9
9
>> (exit)
#f
> (toplevel)
>> (require "bah.ss")
bah!
>>  (require "bah.ss")
>> (exit)
#f
> (toplevel)
>>  (require "bah.ss")
bah!
>>  (require "bah.ss")
>>

Daniel



Posted on the users mailing list.