I think I begin to understand (should have read the report more closely!).
My first mistake was that I tried to export `keyword' in the earlier
version of the first of the following libraries, which makes no sense
because keyword is an unbounded identifier (in fact, chibi-scheme gives me
a warning if I try to export it).:
(define-library (macro-library)
(export macro)
(import (scheme base))
(begin
(define-syntax macro
(syntax-rules (keyword)
((_ keyword) 42)))))
(define-library (wrapper-library)
(export wrapper)
(import (scheme base) (macro-library))
(begin
(define-syntax wrapper
(syntax-rules ()
((_ k) (macro k))))))
(import (scheme base) (scheme write)
(macro-library)
(wrapper-library))
(display (wrapper keyword))
(newline)
My second mistake was that the previously code in the `wrapper-library' and
the program expanded to nonsense. Above are the corrected library and the
corrected program; and now I do understand Alex' answer about `keyword'
nowhere being bound (and thus matching).
That said, my initial question seems to make more sense in the following
example:
(define-library (macro-library)
(export macro keyword)
(import (scheme base))
(begin
; Bind `keyword'
(define-syntax keyword
(syntax-rules ()))
(define-syntax macro
(syntax-rules (keyword)
((_ keyword) 42)))))
(define-library (wrapper-library)
(export wrapper)
(import (scheme base) (macro-library))
(begin
(define-syntax wrapper
(syntax-rules ()
((_ k) (macro k))))))
(import (scheme base) (scheme write)
(macro-library)
(wrapper-library))
(display (wrapper keyword))
(newline)
In this example, `keyword' is bound in `macro-library', so can be exported
by `macro-library'. So, in this case, is it true that this program is not
portable because the binding of `keyword` in the top-level program may be
different than the binding of `keyword' in `wrapper-library' in case
`macro-library' is loaded twice?
(In chibi-scheme, the binding apparently is the same because I get the
answer 42. What confuses me, however, is that chibi-scheme (with
`SEXP_USE_STRICT_TOPLEVEL_BINDINGS=1`) still gives me 42 if I do not export
`keyword` in macro-library. In this case, however, I would have thought
that an unbound identifier `keyword` (as in `wrapper-library' or the
top-level program) never matches...)
Marc
P.S.: I'm sorry in case these kind of questions do not belong on this list.
2014-01-28 Alex Shinn <[email protected]>
> On Sun, Jan 26, 2014 at 9:39 PM, Marc Nieper-Wißkirchen <
> [email protected]> wrote:
>
>>
>> 2014-01-26 Alex Shinn <[email protected]>
>>
>>
>>> Perhaps I'm missing something, but it looks like this should
>>> portably display 42. macro-library was imported by the main
>>> program, so `keyword' refers to that binding. This is passed
>>> through the wrapper to `macro', which sees the `keyword'
>>> binding it expects.
>>>
>>
>> But `wrapper' does not expand into the macro coming from the loading of
>> `macro-library' into the main program, but into the macro coming from
>> loading of `macro-library' into `wrapper-library'. If these two loadings
>> are completely independent (as the standard seems to allow), `keyword'
>> refers to the wrong binding.
>>
>
> Since keyword doesn't refer to any binding in either library, it matches.
>
> --
> Alex
>
>
_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports