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

Re: PATCH: arguments to anonymous function

On 19 June 2011 20:14, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> This adds arguments to anonymous functions.  The only easy way of doing
> this without trampling on other syntax is to pass them after the final
> brace, where previously it would have caused a syntax error so it's
> unproblematic.  I hope that's not going to be too inconvenient.

Cool, I remember wanting this a few times. I just don't remember what
for :). It sort of lets you do array things to globs without assigning
a var first pretty easily, () { print -l /foo/${(U)^@} } Src/*.c

Or arbitrarily nested glob qualifiers, I'm sometimes bothered by not
being able to do foo(xyz)/bar(abc) where xyz would be glob quals to
apply on the foo segment, and abc on bar.

() { () { print -l $^@(e:'REPLY=${(U)REPLY}':) } $^@/*(.) } *(/)
(This is a stupid example, but maybe it gets the point across. :) No
idea why I'm so fond of uppercasing things tonight.)

A heads up, this patch may make zsh crash on startup when reading .zwc
files from before the change. A simple workaround is to either touch
the source file or remove the .zwc files. (Maybe we should bump the
-dev version so this doesn't affect too many people?)

Mikael Magnusson

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