Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Associative arrays, structured namespaces

Zefram <zefram@xxxxxxxxx> writes:

> One of the conventions I established was that all environment
> variables, except for strictly user-generated ones, have structured
> names.  For example, the equivalent of the Unix "PATH" variable is
> called "shell.path".  The equivalent of "LOCALE" is called
> "user.locale".  This means that scripts, or the user at the shell
> prompt, can use *any* alphanumeric variable name, without any risk
> of colliding with anyone else's variables, now or in the future.
> And utility writers have a guaranteed way to define variables
> special to a particular utility without clashing with anyone else's
> variables, so there's none of this "MAILFILE" nonsense.

This strikes me as an excellent idea.  Presumably the implementation
is similar to that of associative arrays, though?  

If you're going to have structured namespaces, I'd like to be able to
use them to do things I'd otherwise use associative arrays for, I
think, so I'd like ways of asking for all variables like "shell.*" and
stuff.  Oh, maybe there are quoting issues I haven't thought of.
Anyway, this looks quite clean.

What's then needed is some way of tying these names to other names, so
that PATH connects correctly to shell.path and so on.  This would be a
good opportunity to generalise things a bit, and allow arbitrary shell
functions to be called when a variable gets set or read, and stuff
like that.

This is all in ksh93, isn't it?  Another reason for doing it.

Messages sorted by: Reverse Date, Date, Thread, Author