#909 closed defect (worksforme)
strange behaviour with define-record and modules
Reported by: | megane | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 4.9.0 |
Component: | core libraries | Version: | 4.8.x |
Keywords: | modules | Cc: | |
Estimated difficulty: |
Description
Might not be define-record specific.
(module m1 (make-foo) (import chicken scheme) (define-record foo a) (let [(make* make-foo)] (set! make-foo (lambda () (make* 1))))) (module m2 () (import chicken scheme) (import m1) ; <- remove this and everything works (define-record foo a)) (import m1) (print (make-foo)) ;; Error: bad argument count - received 0 but expected 1: #<procedure (make-foo a)>
Change History (4)
comment:1 Changed 12 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 Changed 12 years ago by
It is important to remember that modules do not create a separate binding environment. Any imported identifier can be re-assigned and the assignment will modify the global binding (define
and set!
are equivalent at the global level). The module system just renames and resolves global identifiers.
Note: See
TracTickets for help on using
tickets.
I think this is normal, expected behavior. It's functionally equivalent to:
Your test example can be "fixed" by either omitting or renaming
make-foo
from the import specifier form1
. But note that this isn't currently going to work, because record type names must be globally unique (this is arguably a bug which we've tried to fix but the initial fix broke more than it fixed, so we had to revert it)If you disagree this is normal, please re-open this ticket.