* anonymous functions
[not found] ` <AANLkTinerHxXBs4vc_+UXFMxsrui7EKBNhdH01a0wqn6@mail.gmail.com>
@ 2011-02-11 17:17 ` Greg Klanderman
2011-02-11 18:17 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Greg Klanderman @ 2011-02-11 17:17 UTC (permalink / raw)
To: Zsh list
>>>>> On February 11, 2011 Bart Schaefer <schaefer@brasslantern.com> 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, pass as an argument, return from a function, and call at
some later time. They should be called 'local scopes' or 'local
blocks' or even 'blocks', and use their own reserved word.
The concepts are of course related; in lisp-like languages
(let ((a <e1>) (b <e2>) (c <e3>)) <body>)
is of course equivalent to
((lambda (a b c) <body>) <e1> <e2> <e3>)
Greg
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: anonymous functions
2011-02-11 17:17 ` anonymous functions Greg Klanderman
@ 2011-02-11 18:17 ` Bart Schaefer
2011-02-11 18:21 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2011-02-11 18:17 UTC (permalink / raw)
To: Zsh list
On Feb 11, 12:17pm, Greg Klanderman wrote:
} Subject: anonymous functions
}
} >>>>> On February 11, 2011 Bart Schaefer <schaefer@brasslantern.com> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: anonymous functions
2011-02-11 18:17 ` Bart Schaefer
@ 2011-02-11 18:21 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2011-02-11 18:21 UTC (permalink / raw)
To: Zsh list
On Feb 11, 10:17am, Bart Schaefer wrote:
}
} On Feb 11, 12:17pm, Greg Klanderman wrote:
} }
} } Why are these things called 'anonymous functions'? That name connotes
} } lambda
}
} Unfortunately it really only means an unnamed function for scoping
Oops, sorry, I read Greg's sentence as "What are ...?" so the rest of
that doesn't really follow.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-11 18:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <AANLkTikFsJGitoiU49kJphErOsxbCN_BrerNcaHcb2kR@mail.gmail.com>
[not found] ` <AANLkTinerHxXBs4vc_+UXFMxsrui7EKBNhdH01a0wqn6@mail.gmail.com>
2011-02-11 17:17 ` anonymous functions Greg Klanderman
2011-02-11 18:17 ` Bart Schaefer
2011-02-11 18:21 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).