[r6rs-discuss] [Formal] Add a multi-file library example
> I meant that
>
> (library (superlib (5 0))
> (import (sublib 5 0))
> ...)
>
> would be more robust than
>
> (library (superlib (5 0))
> (import sublib)
> ...)
>
> for the aforementioned reason.
Interesting. I use Chez, and in Chez I wouldn't use either of the above
approaches. (I'm talking about importing sublib, not about the presence or
absence of version numbers.) The problem is that if sublib was meant to be
a private part of superlib you've now exposed it; anyone can see it and
import it directly. After all, the sublib "identifier" has to be visible
to the import clause; that means that the library form containing sublib
will have to appear (load, include, something) before the superlib library
form--and at the same level as the library form.
In Chez I would do something like this if I wanted sublib to be private:
(module superlib (...)
(include "sublib.ss")
(import sublib)
...)
That would restrict the visibility of sublib to the superlib module. (In
Chez restricting visibility is important because the more the compiler
knows the more it can optimize. And to really optimize the compiler has to
know that values can't be modified. Just FYI.)
But I don't think you could really do something like that in R6RS. If you
could, it might look like this:
(library (superlib (5 0))
(export ...)
(import r6rs)
(include "sublib.ss")
(library (superlib-internal)
(export ...)
(import r6rs (sublib (5 0)))
...)
...)
Off the top of my head, though, I don't think R6RS libraries can be
nested. And you have to nest because, unlike Chez, R6RS doesn't allow
imports to appear in arbitrary locations. They have to be at the top of a
library form. (In the above example the assumption is that superlib
exports everything superlib-internal does. But of course it all seems a
little artificial and silly. No one would really do that. What would they
gain?)
The bottom line is that with R6RS I think you'd be unlikely to split a
large library into smaller libraries *if* you wanted to keep those library
details private. You'd be more likely to include the library pieces into
the library form directly. Doesn't seem quite right, really. Or: doesn't
seem quite ideal.
So: interesting. Well, to me anyway. :-)
Received on Mon Nov 13 2006 - 18:20:29 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC