On Apr 18, 2009, at 8:02 AM, Michele Simionato wrote:
Consider this library:
#!r6rs
(library (x)
(export)
(import (rnrs))
(display "imported x!"))
Importing it in Ikarus does not print anything; importing it in
Ypsilon or PLT
does print the message.
Importing the library should not print the message. The message is
printed when the library is "invoked", i.e., when its definitions and
initialization expressions are evaluated. For example, if you have a
library:
(library (T)
(export t)
(import (rnrs))
(define t 't)
(display "T invoked\n"))
and a script:
#!r6rs
(import (rnrs) (T))
(display t)
(newline)
You can import (T) into the script (when doing --compile-
dependencies) without getting anything printed out. Any system that
supports separate compilation should make the distinction between
importing and invoking a library (as well as visiting a library).
[So, there are no side effects at import time, as the title says.]
I guess both behavior are consistent with the R6RS
report and that I have found yet another example of inadequate
specification.
This is not new. I, however, don't think that this particular one is
a biggie. The majority of the libraries you're likely to see (e.g.,
*all* the ported srfis) do not depend on one behavior or another.
The question: is there a way to get the message printed in Ikarus?
Ikarus, internally, has "invoke-library" / "visit-library" procedures
that would cause the message to be printed. They're not exported
because they did not seem very useful (read: I never needed them).
Aziz,,,