| I've been thinking about namespace stuff. And I've looked through the posts, but apart from initial criticism about not being implemented, I didn't find much (did I miss something important?). I also think that this should be addressed soon. Although I still wouldn't know how to implement it in Scheme (yet), I have a proposal, based on Python's module system. I think it is one of the simplest: 1. You don't have to say the module you are in (like in CL's "(use-package :blah)"). So no repetitive names, 1 name 1 place. 2. You state dependencies simply by using "import" (and not having to use a separate 'system' such as ASDF, which btw I never liked at all). 3. You can cherry-pick which symbols you want to have referenced in the current module without prefix (i.e. "from blah import foo"). Based on this, here is the proposal. Three (short) commands: "use", "useas", and "use* ", and new 'ssyntax' (am I abusing this?). You "import" a module with: (use 'foo)
This would load file "foo.arc" (found in 'ARC_PATH') in a separate symbol table (maybe use a plain Arc table?), with proper intra-references, etc. From the current module (let's assume that we want to use 'bar' from module 'foo'), you would do: (foo@bar ...)
Before PG used the dot, I was going to propose it, so '@' is not my favorite (and I actually like the dot as it is in arc1, but I prefer the dot for modules, it might seem more natural to outsiders...)To 'import' a module with a different name: (useas 'foo 'fu)
This helps maintaining terseness, (as in defpackage :nicknames, which I usually make very short). The nice thing is that the user gets to decide the nickname.Finally, to select which symbols you want to 'import': (use* '(bar baq baz) 'foo)
I also like hierarchical module systems, so things like: foo@baq@x
should be possible (albeit I have to say that I certainly wouldn't like things such as
"arc@widgets@radio-button-menu-item@accessible-radio-button-menu-item"... ;) ). I've also been thinking about making symbols private within a module by simply naming them like: (def @internal-fn (a b) ...)
There is, to some extent, a convention in CL to name internal stuff starting with '%', which I find nice. With the dot, it would be nicer IMHO, since in UNIX hidden files are in fact prefixed with a dot. I'm
not so sure about really making the access to internal symbols impossible (since I like CL double-colon syntax, it allows for separate test suites, for instance). For a start, something like 'a@b@c' could translate maybe to "(lookup 'a 'b 'c)", and then make it an error that two '@' appear in a row... |