[r6rs-discuss] Library naming ambiguity?
shiro at lava.net
Mon Jun 11 21:47:37 EDT 2007
I might be missing something, but it seems that,
according to 6.1, the <import-spec> of the following import clause:
(import (except (and (1))))
can be parsed either:
(except <import-set> <identifier> ...)
where there's no <identifier>
and <import-set> is <library-reference>
which is (and <version-reference>)
where the firist <identifier> is 'and'
and <version-reference> is (1)
that is, it imports from a library '(and)' of version 1.
where <identifier> is 'except'
and <version-reference> is (and (1))
that is, it imports from a library '(except)' of version 1.
This ambiguity can be removed either by:
 Not allowing 'except' 'only' 'and' etc. as <identifier>s of
 By requring at least one <identifier> in except clause etc.
I don't like the (rather arbitrary) restriction of the former.
Besides, it limits implementations to extend 'import' clause
to allow a new special clauses (in parallel to 'only' etc.)
in upper-compatible way, since such extension might
conflict with legitimate r6rs library names.
The latter can certainly patch this specific problem, but I feel
that the real problem is that the import syntax is too terse,
conflating lists to carry too many meanings. It took some time
for me to grok the import syntax described in 6.1.
A little bit of verbosity would make it easier to parse the
import spec by human, and would remove possible ambiguity and
conflict from extensions. I show my random ideas below
for the sake of discussion, but I don't intend them to be
the best solutions.
- Make 'only' etc. as qualifiers following <library-name>,
instead of making them prefixed clause, e.g.
(import (<identifier> <identifier>...) ; <library-name>, except <version>
only <identifier> ...
except <identifier> ...
Each qualifier modifies the implicit import set in order
it appears. We can also specify version restrictions
in 'version' qualifier like above, which is easier than
including <version-reference> in the <library-name>.
- The above syntax assumes each 'import' clause only imports
from one library, and a 'library' form can have multiple 'import'
clauses. If we really want a 'library' form to have exactly
one import clause, we can go like this:
(import ((<identifier> <identifier>...)
only <identifier> ...
only <identifier> ...)
But I don't think multiple import clauses harm, even if it is
- The current <version-reference> syntax seems to be syntacitically
in parallel with having <version> in the <library-name>. However,
I don't see the advantage of having the version numbers there.
Having separate 'version' clause seems equally plausible to me.
(library (<identifier> ...) ; <library-name>
(version <version>) ; optional verion
More information about the r6rs-discuss