Hi folks!

I've come up with a new scheme to further entrench myself in epic. ;)  The
basic idea or thought is that while packages are good and all it would be
nice to have a more "forceful" container mechanism which could keep things
bundled and keep things from trouncing all over each other as well.  Enter
namespaces.

Here's my basic plan:
I want to add a 'namespace' command which changes the current namespace.
This will be pretty much like the current package command.   Namespaces
will exist from the time of execution to the end of file loading, and will
then revert to the previous namespace.

However, namespaces will behave significantly different.  For one thing,
namespaces will provide a way to give identifiers really unique names by
automatically prepending the identifier with the namespace, followed by a
'::' separator (in line with several implimentations).  So for, example:

namespace foo
alias bar (...) {....}
assign baz quox
namespace

Will actually create a foo::bar alias and a foo::baz assign.  Aliases and
assigns will always be available using their full names.  In addition to
that any aliases or assigns that 'bar' might create will automatically be
in the 'foo' namespace.

Also, any hooks[1], key binding functions, and non-default key bindings
will be contained within namespaces.  This will allow for a simple
mechanism to "remove" any traces of a namespace, sort of like unloading a
package now, but much more complete.

However, this will have a much more useful side effect, which is to allow
different pieces of script to declare aliases and assigns with the same
name without having collisions and confusion.  With this of course will
come a symbol resolution schema which will probably work something like
this:
1) Check to see if symbol is fully qualified (contains ::)
2) Check to see if symbol exists in the current namespace (unless the
   current namespace is the global[2] namespace)
3) Check to see if symbol exists in any using[3] namespaces
4) Check to see if symbol exists in the global namespace

If the symbol comes up empty one of two actions is taken.  If the symbol is
being acessed/defined in a non-global namespace it becomes a member of that
namespace, otherwise it becomes a member of the global namespace.

Comments, suggestions, etc?

[1] I have some extra ideas about hooks which I'm going to send a followup
    email about.
[2] The 'global' namespace is simply '::' (or a namespace with no name).
    Referring explicitly to the global namespace would require '::foo.'
    This might cause some collision with local/global scope variables,
    so I'm open to suggestion here.
[3] I would also add a 'using' or 'use' command to add namespaces into
    a list of namespaces to always search for symbol resolution.  That
    might be deemed unnecessary though, and in that case could be left out.

-wd
-- 
chip norkus; unix geek and programmer;          [EMAIL PROTECTED]
"question = (to) ? be : !be;" --Shakespeare     http://telekinesis.org/
_______________________________________________
List mailing list
[EMAIL PROTECTED]
http://epicsol.org/mailman/listinfo/list

Reply via email to