[R6RS] Re: Implicit exports
R. Kent Dybvig
dyb
Sun Sep 26 23:39:08 EDT 2004
> Could you post an example to R6RS where pure SYNTAX-RULES potentially
> would drag in way too many identifiers by way of implicit exports?
I assume you mean where a scan of the output templates of exported
keywords might find "way too many" false implicit exports.
Let me try instead to explain the situations in which this can occur;
this should enable you to construct your own examples.
Incidentally, I don't know how many is "way too many" for anyone else.
For me, the number is pretty small (somewhere around one), since even
one can result in an unexpected and difficult to find loss of analysis
information and/or performance.
There are two cases to consider:
1. The standard language includes only pure syntax-rules and we
don't care what happens to implementations that provide anything
like syntax-case.
2. The standard language includes something like syntax-case as well
as syntax-rules or we do care what happens to implementations that
provide something like syntax-case.
In case 1, a scan can find false implicit exports when
a. the output template of a syntax-rules form of an exported keyword
contains a quoted symbol that happens to be the name of a local
binding,
b. the output template of a syntax-rules form of an exported keyword
contains an occurrence of an unexported keyword, and the
output template of the syntax-rules form of the unexported keyword
contains a quoted symbol that happens to be the name of a local
binding, or
c. any sequence of keyword and symbolic references in the sense of
(a) and (b) finds us scanning a template containing a quoted symbol
that happens to be the name of a local binding.
(I'm assuming that we won't permit a programmer to construct a module
containing shared, cyclic, or unscannable implementation-dependent or
record data, which in some cases could force all module bindings to be
treated as implicit exports. This assumption is likely not to hold in
some Scheme implementations.)
In case 2, a scan can find false implicit exports additionally when
d. the output template of a syntax-rules form of an exported keyword
contains any identifier that names or might end up in the hands
of a ``low-level'' macro, which may then construct the name of any
module binding.
In situation (d), the system must treat all module bindings as implicit
exports.
Scanning syntax-rules templates sounds nice in theory, but breaks down
in the worst sort of way, in my opinion, even in a system that supports
only syntax-rules. Quoted data that otherwise has no material affect
on a program's operation should never affect the quality of analysis
and optimization, but, with scanning for implicit exports in lieu of
listing them, it would.
Listing implicit exports is of course a burden on the module writer,
but the burden is small in my experience and more than justified for
code that ends up in shared libraries.
Kent
More information about the R6RS
mailing list