This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Unnamed functions, functors or, more formally, function literals
- From: dewar at gnat dot com (Robert Dewar)
- To: kewarken at qnx dot com, pkoning at equallogic dot com, sd70030 at lanet dot lv
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 15 Mar 2002 11:09:16 -0500 (EST)
- Subject: Re: Unnamed functions, functors or, more formally, function literals
<<I'm not saying that this should be added to C since, well, then it wouldn't
be C now would it? But I wouldn't write them off as less than useful. Try
using it for GUI programming some time. It's wonderful to pass a function
to be called when such and such button is pressed without having to define
it in the global or class namespace, especially if the action for the button
is something very simple.
>>
Puzzlement ... in GNU C, you can perfectly well pass the address of a
local function. Now if you are saying you want full closures so that there
are no out-of-scope problems, that's OK, but actually not many languages
*do* have full closures, and they are very hard to implement in the absence
of garbage collection (in fact I don't see anyway of implementing them with
no GC).
Certainly the suggestion of adding full closures to C is way out of scope.