On Tue, Sep 22, 2009 at 10:03:48AM -0400, John Cowan wrote:
> 
> Actually, if you quote the compiled procedure, most Schemes' "eval"
> will allow it:
> 
>         > (define x `(car '(a . b)))
>         > (set-car! x `(quote ,car))
>         > (eval x (interaction-environment))
>         a
> 
> I tested Chicken, SCM, Gauche, Gambit, Guile, Bigloo, and Chez
> successfully.  MIT Scheme doesn't like "interaction-environment",
> mzscheme doesn't like "set-car!", and Scheme48/scsh report vm-exceptions
> when doing the set-car!.

May I suggest: (eval `(',car '(a . b)) (interaction-environment))

The thing for MIT Scheme seems to be (nearest-repl/environment), but
it refuses to apply the naked procedure regardless.  SCSH warns about
evaluating the quoted closure, but proceeds.  MzScheme doesn't have
interaction-environment in its default language, but it will take the
one-argument form of eval, and works in that manner.

Larceny is also just fine with this, though it does not recognize the
procedure as being "car" for the purpose of optimizations.

-- 
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to