Closed ovenpasta closed 8 years ago
The auxiliary keyword identifiers (<>
and <...>
) must be exported from the library if they're ever going to match an identifier from outside the library. This behavior is not entirely obvious, but it is implied by the documentation for syntax-rules
and free-identifier=?
I've tried adding <>
and <...>
to the exports... but....
> (import (srfi s26 cut))
Exception: missing definition for multiple exports, including <...> at line 9, char 23 of /home/aldo/thunderchez/srfi/s26/cut.sls
Type (debug) to enter the debugger.
Yep, you also need to add some kind of syntactic binding for these. You can do this with something like:
(define-syntax <>
(lambda (x)
(syntax-violation #f "misplaced use of auxiliary keyword" x)))
I have a couple of handy macros I use for this in the nanopass framework:
(define-syntax define-auxiliary-keyword
(syntax-rules ()
[(_ name)
(define-syntax name
(lambda (x)
(syntax-violation 'name "misplaced use of auxiliary keyword" x)))]))
(define-syntax define-auxiliary-keywords
(syntax-rules ()
[(_ name* ...)
(begin (define-auxiliary-keyword name*) ...)]))
Then you can do something like:
(define-auxiliary-keywords <> <...>)
thank you! now it works properly ;)
For future reference if anyone stumbles across this: if you have two modules both using <> and <...> you can't have both export their own version of it.
You will have to define them in one module, and then have the other import and re-export them.
Hello, It's not the first time I have problems with wrapping macros inside libraries. Here is a simple example that is happening lastly:
https://github.com/ovenpasta/thunderchez/blob/master/srfi/s26/cut.scm If I load this with
(load "cut.scm")
or(include "cut.scm")
it is behaving properly:Instead if use the wrapped code inside the library: https://github.com/ovenpasta/thunderchez/blob/master/srfi/s26/cut.sls
Best regards