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

Re: revisiting passing arrays to functions



On Oct 20,  5:32pm, Filipe Silva wrote:
}
} I searched through the archives and found this message about passing arrays
} to functions: http://www.zsh.org/mla/users/2011/msg00967.html
} 
} But that was in 2011. Is that changed? Do we have a way to pass zsh
} arrays to a zsh function in a comfortable way?

Please define "comfortable"?  (I guess I should ask PWS that.)

The semantics of the (P) expansion flag have been improved, so that for
example in 5.2 it works more sensibly with nested substitutions and also
with associative arrays, which was practically impossible before.  

However, there's been nothing done to enable, for example, passing an
array as a pointer, because shell functions do not have named/typed
argument call signatures.  It's still necessary to pass the name of
the array in a positional parameter and then apply (P) to that, with
all the corresponding consequences around scoping of the name, e.g.,
possible clashes with locals declared in the function.



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