Closed lassik closed 1 year ago
Hi @lassik You need SRFI-9 for that...
But then there's the real problem:
(define-library testlib
(import (scheme base) (srfi 9))
(begin
(define-record-type <test-record>
(make-test-record name)
test-record?
(name test-record-name))))
**** Error:
%execute: symbol `make-struct-type' unbound in library (testlib)
Ah, that is a problem indeed!
The primitive make-struct-type
exists, but it's not being exported to a library that imports SRFI-9:
stklos> (define-library y (import (srfi 9)))
;; y
stklos> (in-module y make-struct-type)
**** Error:
symbol-value*: symbol `make-struct-type' unbound in library (y)
@egallesio -- SRFI 9 naturally inherits make-struct-type
and everything else from the STklos
module, since it is itself a module, but it exports define-record-type
, which is syntax, and which depends on a primitive (which SRFI-9 should not export).
When a library imports (srfi 9)
, it brings the macro, but not the symbols referenced by the macro (this is one of the pending issues for hygienic macros... They should remember the environment when they were defined).
What would a feasible workaround for now?
I mean... @lassik - this would work, but it brings all Scheme symbols into the library:
(define-library testlib
(import SCHEME
(srfi 9))
(begin
(define-record-type <test-record>
(make-test-record name)
test-record?
(name test-record-name))))
Thanks for looking into it!
You need SRFI-9 for that...
The R7RS standard does not provide a (srfi 9)
library. It should be possible to import (scheme base)
and get a working define-record-type
. (IIRC the R7RS semantics are the same as in SRFI 9, but I'm not 100% sure about that.)
it brings the macro, but not the symbols referenced by the macro (this is one of the pending issues for hygienic macros... They should remember the environment when they were defined).
Indeed.
The R7RS standard does not provide a
(srfi 9)
library
Oh, sorry! I forgot that define-record-type
was in R7RS! :)
So one would just need to add define-recrord-type
and its dependencies to (scheme base)
to fix this... Seems easy, actually.
Yes, but neither (scheme base)
nor (srfi 9)
should export internal procedures that are called by the define-record-type
macro.
I'm fixing this issue. Thanks for signaling it.
The last commits correct this issue.