[plt-scheme] an r6rs library compatible repl?
Rohan Drape said:
> the actual problem i have is related to
> mpairs. i've an r6rs library that i'd
> like to use ... from an
> repl.
> but list
> processing doesn't work, since the libraries need
> mutable pairs and the repl is making immutable
> lists.
>
> $ mzscheme
> Welcome to MzScheme v3.99.0.17 [3m], Copyright (c) 2004-2008 PLT Scheme Inc.
> > (require rnrs/lists-6)
> > (filter even? (list 1 2 3 4 5))
> mcar: expects argument of type <mutable-pair>; given (1 2 3 4 5)
>
> is there a switch i can give mzscheme to make
> it generate mlists? (ie. to make an r6rs +
> udp repl?)
To get an R6RS REPL, which makes mutable pairs, I've been using a
DrScheme buffer with the language set to "Module" and with something
like the following in the Definitions Window:
#!r6rs
(import (rnrs))
and then I click "Run" and use the Interactions Window. I.E.:
Welcome to DrScheme, version 3.99.0.19-svn18mar2008 [3m].
Language: Module.
> (filter even? (list 1 2 3 4 5))
{2 4}
>
The curly brackets show it's using mutable pairs.
I just started doing this. I'm not yet sure if there are any caveats
with regard to this REPL mode vs strict R6RS semantics. You can do the
following, which violates R6RS body semantics, but is of course useful
in a REPL:
;;; After setting up to use the #!r6rs (import (rnrs)) module language
Welcome to DrScheme, version 3.99.0.19-svn18mar2008 [3m].
Language: Module.
> (define x)
> x
> (define y (begin (set! x 123) 456))
> x
123
> y
456
> (define x 'new) ;; couldn't do this in a library or top-level program
> x
new
>
--
: Derick
----------------------------------------------------------------