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: Erik Trulsson <ertr1013 at student dot uu dot se>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 16 Mar 2002 01:20:06 +0100
- Subject: Re: Unnamed functions, functors or, more formally, function literals
- References: <20020316000625.56AC3F28C4@nile.gnat.com>
On Fri, Mar 15, 2002 at 07:06:25PM -0500, Robert Dewar wrote:
> <<If they are useful or not is mainly a matter of programming style.
> Personally I like them, but then I am familiar with functional
> languages where anonymous functions are an important part of the
> language. (Program in List or ML for a while, and I think you will see
> how they can be useful.)
> >>
>
> Well I don't know List, but I have programmed extensively in Lisp and other
> functional languages, and I don't see things the way you do at all. This is
> just a convenience of binding issue, not anything that reflects issues of
> expressive power (this is true in both functional and procedural languages).
[I meant Lisp, not List. Sorry for the typo.]
Yes, of course it is a convenience but so is a lot of other stuff in
most programming languages. One could probably remove a large part of
most languages without reducing their expressive power.
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.
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se