shirok / Gauche

Scheme Scripting Engine
https://practical-scheme.net/gauche
Other
812 stars 81 forks source link

[R7RS] exporting imported identifiers from a library definition is broken #41

Closed jwtowner closed 10 years ago

jwtowner commented 10 years ago

The next problem I've run into is exporting identifiers from an R7RS library definition that have been imported into it from another module. I'm wrapping some procedures/macros so that I provide a common portable interface to the rest of my codebase. One of the things I'm abstracting here are hash tables, that way I have a subset of the interface that matches the upcoming R7RS-large specification (pretty close to R6RS/SRFI 69).

Unfortunately, being able to forward identifiers via the export list seems to be broken in Gauche, whereas it works in both Chibi and Chicken Scheme implementations when running in R7RS mode. Here's how to reproduce the problem:

testlib.scm

(define-library (testlib)
  (export make-hash-table hash-table?)
  (import
    (only (gauche base) hash-table?)
    (prefix (gauche base) gauche:))
  (begin
    (define (make-hash-table)
      (gauche:make-hash-table 'equal?))))

Then I run gosh, load and import the library, and try to use the exported procedures. Here's what happens:

$ gosh -r7 -I. -ltestlib.scm
gosh[r7rs.user]> (import (testlib))
#<undef>
gosh[r7rs.user]> (define ht (make-hash-table))
ht
gosh[r7rs.user]> ht
#<hash-table equal? 0x1947780>
gosh[r7rs.user]> (hash-table? ht)
*** ERROR: unbound variable: hash-table?
Stack Trace:
_______________________________________
  0  (hash-table? ht)
        At line 4 of "(standard input)"
  1  (eval expr env)
        At line 220 of "/usr/local/share/gauche-0.9/0.9.5_pre1/lib/gauche/interactive.scm"
gosh[r7rs.user]> 

hash-table? should be bound to the hash-table? procedure imported from (gauche base) inside of (testlib).

shirok commented 10 years ago

Actually, the bug is not about exporting imported identifiers; it's in importing the same module more than once but with different qualifiers (once & prefix, in this case). I pushed the fix.

jwtowner commented 10 years ago

Thanks for the clarification, and thank you for the fix, it's working for me now!