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

Re: db module



On Sun, Oct 06, 2002 at 01:32:29AM -0400, Clint Adams wrote:
> > typeset -A things -S db -f /tmp/newdb
> > typeset string -S mapfile -f /tmp/file
> 
> Someone suggested tying assocs to functions, so we could add something
> like
> 
> f() { print $(( $1 * 2 )) }
> typeset -A twice -S function -f f
> print $f[2]
> 
> I'm not sure that there are any useful applications for this though.

As demonstrated above, I can't see how it's any better than calling f()
directly.  However, if the function got an extra argument when an element was
assigned to, it could be pretty neat, e.g.:

f() { [ "$2" ] && echo $2 > $1; cat $1 }

hdp.



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