Will Hartung <willh@msoft.com> wrote:
+---------------
| Java may well have "closures", but as you've discovered, they're not
| popular simply because of the flaming hoops you have to jump through
| in order to actually use them. So, they're not "handy" and take "work".
+---------------
Well, if "not handy" and "takes work" doesn't disqualify them, then
even *C* "has" closures -- just declare something like this: ;-}
struct closure {
void *function;
void *env_data;
};
Or to say it another way, the common C idiom of passing both a
callback function and an opaque-data cookie (to be passed to
the function when it's called) is in some sense "just a closure",
split over two args.
+---------------
| Lisp has handy closures, so we drop them all over the place without
| a second thought. Java has Flaming Hoop closures so they never see
| the light of day.
+---------------
Even in C "closures" get used *occasionally* -- I used them once
in some firmware for an ATM interface. [Confession: I prototyped
the code in Scheme, and when I hand-compiled it to C, I couldn't
see any easy way to avoid using a closure, so I used one.]
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607