News for hackers. Stuff that matters.
Re:List Processing in C by gjm11 on Tuesday December 21, 2010 @06:38AM (#2027535)
It's not only that C doesn't have closures; it doesn't even have anonymous functions. Here's a little Lisp expression that doesn't need closures

  (mapcar #'(lambda (x) (* x x)) some-list)
which squares all the elements of the list. To do that in C you need some abomination like

  /* Somewhere outside the function where you actually need this */
  int square(x) { return x*x; }
  
  /* ... */

    List *r = List_new();
    LIST_FOREACH(self, i, v, List_append_(r, square(v)););
Not to mention that this sort of thing tends to get ugly without automatic memory management.

There are no comments on this comment yet.