On 14-Jan-09, at 1:04 PM, Per Eckerdal wrote:
(Sorry Christian, I forgot to Cc this mail to the list, so you'll get this mail twice)
Christian Jaeger wrote:
When I think about it, it is not that hard to interface to "legacy" code, using the namespace system. The module system actually uses it internally. Only partially, and I'm hoping to remove it relatively soon, because as I said, it's not nice to work with, but the naming convention namespace#identifier is used and I don't see why that would change.
You haven't said what isn't nice.
- When do I use ##namespace and when can I use just namespace? It's a
little bit odd.
Not at all... remember that a fully qualified identifier (i.e. which contains a # sign) is an "absolute name". Names without a # sign are relative, and the current namespace scope decides what they actually resolve to.
So the code
(let ((a 10)) (namespace ("foo#")) (and a b))
is equivalent to
(let ((a 10)) (foo#and foo#a foo#b))
By the same logic,
(let ((a 10)) (namespace ("foo#")) (namespace ("bar#" a b)) (and a b))
is equivalent to
(let ((a 10)) (foo#namespace ("bar#" foo#a foo#b)) (foo#and foo#a foo#b))
It may be surprising that the second namespace was not treated as a namespace declaration, but it is consistent because the first namespace changed the meaning of the second reference to "namespace".
The code could be written
(let ((a 10)) (namespace ("foo#")) (##namespace ("bar#" a b)) ;; this is really a namespace declaration (and a b))
or use ##namespace everywhere or use:
(let ((a 10)) (namespace ("foo#") ("bar#" a b)) (and a b))
- The fact that (namespace ("foo")) and (namespace ("foo" bar)) does
two completely different things is definitely not nice. (namespace ("foo")) ought to be something like (namespace "foo") instead. Automatic tools need to be careful not to insert an empty list of identifiers that belong to a namespace, since that is something completely different.
Good suggestion.
- I find (namespace ("foo")) quite difficult to tame. It's easy to
mess up lots of things, including the repl when working with it.
- Maybe I should have been clearer in what I meant with the "namespace
system": In my eyes the ##namespace directive is very closely tied to the concept of having separate #.scm and .scm files, and the way it is used in practise is broken in my opinion.
I agree that the separation is awkward (very C like). But a module system can hide the ##namespace declarations so that users never have to see them.
Using namespace prefixes for the automatic naming of identifiers deems me a good idea for these reasons:
- code always needs to specify a dependency somehow; so you will
always have the problem of unique global naming in some way or another.
Yes. My point was that using prefixes is a solution that is much inferior to other possible solutions.
All solutions boil down to prefixing of one form of another. For example filesystem paths are really a prefixing solution. Same for domain names, URLs, etc.
Note: I'll have to look at your system before I make more comments.
Marc