[r6rs-discuss] Library naming ambiguity?

From: Shiro Kawai <shiro>
Date: Mon, 11 Jun 2007 15:47:37 -1000 (HST)

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.

or

  (<identifier> <version-reference>)
    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:

[1] Not allowing 'except' 'only' 'and' etc. as <identifier>s of
    the library.

[2] 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.

Some ideas:

- 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> ...
          version <version-reference>)

  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> ...
           except ...)
          ((<identifier> <identifier>...)
           only <identifier> ...)
          ...)

  But I don't think multiple import clauses harm, even if it is
  technically verbose.

- 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
    (export ...)
    (import ...)

    body ...)
  

--shiro
Received on Mon Jun 11 2007 - 21:47:37 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC