On Wed, 2008-10-29 at 22:04 -0700, Michele Simionato wrote:
> So, I was reading again the R6RS document, especially the part about
> phase separations which I had dismissed in the past, and I have found
> the following sentence:
> """
> An implementation may distinguish instances/visits of a library for
> different phases or to use an instance/visit at any phase as an
> instance/visit at any other phase. An implementation may further
> expand each library form with distinct visits of libraries in any
> phase and/or instances of libraries in phases above 0. An
> implementation may create instances/visits of more libraries at more
> phases than required to satisfy references. When an identifier appears
> as an expression in a phase that is inconsistent with the identifier’s
> level, then an implementation may raise an exception either at expand
> time or run time, or it may allow the reference. Thus, a library whose
> meaning depends on whether the instances of a library are
> distinguished or shared across phases or library expansions may be
> unportable.
> """
> Basically the R6RS module system does not guarantee portability, which
> I thought was the point of it :-( I feel depressed, but let it be.
> Now, I was experimenting with phase separation. Here is an example
> that works with PLT Scheme:

I assume you're doing "plt-r6rs --install test1.sls"?  This separates
the libraries into multiple new files which are put into a PLT
"collects" directory.  Otherwise, I'm pretty sure PLT doesn't support
multiple libraries in a single file.  I don't use "plt-r6rs --install"
because then you can't work with the same files across implementations.
I tell PLT to include in its set of "collects" directories the same
single directory I use for all implementations, by just symlinking my
directory into my $HOME/.plt-scheme/$PLT_VERSION/collects/ .  It's not
necessary to use "plt-r6rs" to run R6RS programs, you can run them with
just "mzscheme an-r6rs-program.sps" or just do "run" in DrScheme.  I
believe PLT made this plt-r6rs so that libraries can be installed so
they follow PLT's conventions (requiring #!r6rs at the file's top, and
library (foo) is found at $COLLECTS/foo/main.sls) and to support
multiple libraries in one file.

Someone could make an installer for Ikarus that tries to be smart about
what you tell it and extracts libraries and installs copies according to
Ikarus's conventions.  But because this interferes with working with the
same files across implementations, I'd much rather things go in the
direction of a convention which works across all implementations.  I've
had no problems using the same directories and files on Ikarus, PLT, and
Ypsilon, with using the *.IMPL.sls convention for
implementation-specific libraries.  Larceny is supposed to support this
convention soon.

> Of course, this example does not work with Ikarus with error "expected
> to find library (test1) in file ./test1.sls, found (test1 helper1)
> instead"

If you "load" the file into ikarus, then those libraries are available
for importing.  I.e.:

Ikarus Scheme version 0.0.3+ (revision 1654, build 2008-10-29)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (load "test1.sls")
> (import (test1))
> (world)
(1 1)hello!world > 

> Should I give up the idea of keeping the library in a single file?
> This is unfortunate, I thought this was a feature of the R6RS module
> system. Any hint is much appreciated :-/

The R6RS does not specify how libraries are to be found in files.  I'm
undecided on whether this was good or bad.  Good maybe because it allows
experimentation and innovation.  Bad maybe because a convention is not
agreed on yet.

I believe Larceny plans to or already does support locating
sub-libraries in a single file, i.e.: libraries (foo), (foo bar), (foo
zab), (foo zab blah), could all be found in $LIBRARIES_PATHS/foo.sls
before looking in separate files.  This seems interesting, but adding
complexity to the number of permutations of "where the hell is this
library", but maybe the flexibility is worth it.

-- 
: Derick
----------------------------------------------------------------

Reply via email to