>I've been wondering, lately, about lambda-expressions. Most programming
>languages support and...
Most do? Not that I know of. I suppose Java has the anonymous class
instantiation, which is close to -- but not quite -- a lambda expression.
Anyway, lambda expressions are a convenience for the lazy. If care
is not taken, they yield unmaintainable code. They discourage
reusability of that tidbit of code. But it's sometimes useful,
particularly considering that it associates small bits of code
most closely with their use.
Consider if you could do the following in C...
f ( arg1, ((int)(int i))
{
return i+1;
}
);
... here we are, in effect, defining a function which returns an
int and take an int argument and then passing it on the fly to the
invocation of f. To have done this otherwise, we would have had to
fully define this function somewhere else, and pass in a function
pointer.
In languages which make frequent use of lambda expressions, the
most frequent use is often in passing small bits of code to
functions which do regular transformation of container objects.
In lisp, for example, we have the classic map/lambda combination,
where a new list is derived from a lambda applied to each
element of the list with the new list being composed of the
individual transformation implied by each lambda call.
C//