How to (eval ...) in a chicken r7rs library?

291 views Asked by At

I am trying to get a basic eval to work within a library of the r7rs egg. The following toplevel (not library) program work as I expected, when run with csi -R r7rs:

(import (scheme base)
        (scheme eval))

(eval '42 (scheme-report-environment 5))

This works for (null-environment 5), too (but not with the (environment '(scheme base) ...) variant by the way). However, within a library:

(define-library (test-eval)
  (import
    (scheme base)
    (scheme eval))
  (export
    my-eval)
  (begin
    (define (my-eval)
      (eval '42 (scheme-report-environment 5)))))

I get

Error: module unresolved: test-eval
....
<syntax>          [my-eval] (scheme-report-environment 5)
<syntax>          (##core#begin)
<syntax>          (##core#undefined)    <--

What could be the problem? It seems there were some issues with R7RS environments in the Wiki, but I am not sure if that's related here.

Tested with chicken version 5.2.0 (homebrew package), both csi and csc.

1

There are 1 answers

0
lubgr On BEST ANSWER

I asked about this issue on the Chicken mailing list and immediately got help. First, for scheme-report-environment, there need to be an additional import

(import
   (scheme base)
   (scheme eval)
   (only (scheme r5rs) scheme-report-environment))

There were also two bugs in Chicken - which were fixed within one day (!) (see the mailing list archive). With version 1.0.3 of the r7rs egg, eval now works as expected within a library.