[plt-scheme] Redefining in Mzscheme with legacy R5RS support
I want to run MzScheme with legacy R5RS support enabled but I came
across with a bit strange behaviour:
$ mzscheme -l scheme -l r5rs/run
Welcome to MzScheme v4.1.5 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.
R5RS legacy support loaded
> (define (filter pred x)
(cond ((null? x) '())
((pred (car x)) (cons (car x) (filter pred (cdr x))))
(else (filter pred (cdr x)))))
> (filter (lambda (x) x) '(1 2 3))
filter: expected argument of type <proper list>; given (2 3)
=== context ===
[...]/lib/plt/collects/scheme/private/list.ss:182:2: filter stdin::1: filter
[...]/lib/plt/collects/scheme/private/misc.ss:74:7
However, if I redefine the filter once more in the REPL, then
everything works:
> (define (filter pred x)
(cond ((null? x) '())
((pred (car x)) (cons (car x) (filter pred (cdr x))))
(else (filter pred (cdr x)))))
> (filter (lambda (x) x) '(1 2 3))
(1 2 3)
So it seems that if I invoke mzscheme with -l scheme -l r5rs/run,
then, somehow, the recursive filter function is not entirely
redefined. It looks like the recursive call to (filter pred (cdr x))
still uses the original mzscheme language version which doesn't accept
mutable pairs. Is this a bug or a feature?
Is there any way to get the R5RS definitions and mzscheme language
with these newer versions of MzScheme?
--
Timo Lilja