[plt-scheme] an r6rs library compatible repl?
a reworked question first, reply below.
the actual problem i have is related to
mpairs. i've an r6rs library that i'd
like to use with a upd socket from an
repl. ie.
(require local/r6rs/libraries
scheme/udp)
the r6rs bytevectors work with the socket 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?)
reply:
eli:
> The thing is that (PLT) Scheme is way more flexible than other
> languages, which makes `emptiness' a questionable concept. My version
> was empty to an extreme, for example, the equivalent example using
> prefixes as show in:
>
>> (perhaps something along the lines of:
>> http://haskell.org/onlinereport/modules.html#sect5.3.2)
thanks, i have managed to learn why
(module x (only-in scheme/base) ...)
is not much use, all of the semi-opaque #%
infrastructure disappears. and of course
i recognize plt modules are obviously more
flexible than haskell etc. but hadn't realized
some of the implications, it does seem to make
avoiding simple name collisions with
scheme/base rather tricky? (i mentioned
the haskell example because the prelude
is also slightly anti-symetrical to ordinary
module use since it is implicit, and you
need to add a line to make it go away. also,
i was hoping for an 'only-in' solution instead
of an 'all-except' solution because i already
had an 'only-in' list of all the required
names from the r6rs variants import list).
btw. the empty variant i had turned out to be
of no use because it interacted badly with
syntax in a way i did not understand (libraries
would build but could not be used because #%app
didn't exist as a 'syntax transformer'.)
writing an scheme/empty base language module
that has all of the required infrastructure
to write programs & libraries using define/lambda &
define-syntax/syntax-rules seems non-obvious,
to an 'outsider' at least.
> uses many `#%app's etc -- and if you want to give them new names you
> can, but it makes the code much more verbose:
>
> (module x2 "empty.ss"
> (#%require (only scheme/base require only-in prefix-in))
> (require (prefix-in scheme.
> (only-in scheme
> #%app #%datum provide define lambda + printf)))
> (scheme.provide succ)
> (scheme.define succ
> (scheme.lambda (n) (scheme.#%app scheme.+ n (scheme.#%datum . 1))))
>
> (scheme.#%app scheme.printf (scheme.#%datum . ">>> ~s\n")
> (scheme.#%app succ (scheme.#%datum . 7))))
>
>
>> (also, one could hopefully write a lot of scheme without
>> encountering #%require #%app #%top #%datum and
>> #%module-begin.)
>
> Not really -- but they appear implicitly which is why you usually
> don't care about them. They're really useful when you want to change
> the semantics of the language in a very fundamental way.