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

Re: anonymous functions



On Feb 11, 12:17pm, Greg Klanderman wrote:
} Subject: anonymous functions
}
} >>>>> On February 11, 2011 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} 
} > If your zsh is recent enough to have anonymous functions
} 
} Why are these things called 'anonymous functions'?  That name connotes
} lambda, which would create an unnamed function you could store in a
} variable

Unfortunately it really only means an unnamed function for scoping, so
you can use "local" and "return" to save/restore variables and set the
status.  It does not connote a closure (is not like a lambda expression).

This is partly for simplicity of the implementation, but partly because
the shell language doesn't really provide a syntax for returning values
from functions or commands (except in the limited context of $(( ... ))
math expressions) -- hence all the hacks with $REPLY.

See zsh-users/15575 from last November:
	http://www.zsh.org/mla/users/2010/msg00874.html



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