Unnamed functions, functors or, more formally, function literals
Erik Trulsson
ertr1013@student.uu.se
Fri Mar 15 16:42:00 GMT 2002
On Fri, Mar 15, 2002 at 07:30:49PM -0500, Robert Dewar wrote:
> <<The main convenience IMO of anonyomous functions is that one does not
> need to come up with a new name every time one needs a function that is
> only to be used once. This can also be achieved if one has nested
> functions since then one can reuse the same name if necessary but one
> can use pretty much the same arguments for and against nested functions
> as for anonymous functions.
> >>
>
> Sorry, I don't understand the last sentence, we have nested functions
> now. So what are you arguing for, you seem to say that if you have
> nested functions then it is not so important to have anonymous
> functions. If that is not what you are saying please clarify.
I am not really arguing *for* anything, I am mainly arguing *against*
the notion that anonymous functions are somehow useless.
And, yes, I am saying that many of the benefits of anonymous functions
can be obtained using nested functions. Sometimes anonymous functions
could give shorter and more readable code than using nested functions
but not always.
My position can be summed up as: I like anonymous functions and would
not object to seeing them added to GNU C (provided it can be done in a
reasonably sane manner), but I am certainly not going to lose any sleep
if they are not added.
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
More information about the Gcc
mailing list