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

Module hierarchies, aliasing, and dependencies



At present, the name used to load a module is the only indication zsh has
of whether a particular module is has been loaded.  This is used both by
the dependency system and by the zmodload command.  So for example if one
does

	module_path=($module_path $^module_path/zsh)
	zmodload zleparameter

one has now loaded zsh/zleparameter, but zsh doesn't know it; and loading
it again as zsh/zleparameter fails (because the widgets variable is read-
only).  Even modules that can be successfully loaded more than once give
lots of error messages like:

zsh/zle: name clash when adding hook `list_matches'
zsh/zle: name clash when adding hook `complete'
zsh/zle: name clash when adding hook `before_complete'
zsh/zle: name clash when adding hook `after_complete'
zsh/zle: name clash when adding hook `accept_completion'
zsh/zle: name clash when adding hook `reverse_menu'
zsh/zle: name clash when adding hook `invalidate_list'

Of course this can be written off as misuse of zmodload and $module_path.
However, suppose I have my own locally-hacked version of the "files"
module (adds chmod and mkfifo, or some such).  I'd like to make both
this module and the distributed zsh/files module available for loading.
If I put it in the default module path, under a different hierarchy --
say, /usr/local/lib/zsh/3.1.9/local/files -- then it can be loaded with
"zmodload local/files", but it won't satisy dependencies on "zsh/files".
I could put my local one in a completely different directory in the
module_path -- /usr/local/lib/zsh/local, or something -- still under the
name zsh/files, so that it satisfies the dependencies; but then there's
no way to load some local modules and other standard modules without
changing the value of $module_path before every zmodload.

Wouldn't it be better to rely on a symbol that's defined *inside* the
module to determine whether a module has been loaded?  Similar to the way
(provides 'name) works in emacs libraries?

One way to approach this would be to add another function, like the boot
and cleanup functions that already exist, which is called when searching
the list of modules.  We could define this function to return a string
that is compared to the module being searched for; or we could pass the
string being searched for into the function and let it return a truth
value.  If the function isn't defined by a given module, then compare the
name strings as is done now.

Does anyone foresee any serious problems with such an approach?  Is there
a better way?  Is there disagreement over whether this is worth doing?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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