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

Re: Magic associative arrays (and more)



Bart Schaefer wrote:

> There are a whole lot of fun things we could do with special associative
> array paramters.  Examples:
> 
> An AA named "functions" that looks up values in the shell function hash
> table.  `functions foo` would be the same as `print $functions[foo]`.  The
> "functions" AA could be read-only, but perhaps it would be fun to be able
> to edit the function with `noglob vared functions[foo]`?

Looking at some of the completion example function makes this look
interesting, too, e.g.:

  - being able to test for the existance of a function with
    `${+functions[foo]}' would allow us to conditionally call the
    `_match_*' functions
  - having `$commands[foo]' give the path of `foo' would allow us to
    remove the `$(whence -p ...)' in `_normal'
  - with `${(k)parameters}' we could get rid of that horrible
    expression in `_brace_params' (is there really no easier way
    currently?)


Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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