My today's CUFP won't have any code, just a huge Thanks to Perl for supporting closures.

Today I was dealing with some C code, this code was using dlopen to get some shared object and call some function to it. I couldn't change the API, but needed the called function of some specific plugin to behave differently according to some data I have only when getting the pointer to that function. I thought: well, a simple closure will solve the problem, but no... C doesn't support closures...

Fortunally, some guys at ##C at freenode helped me and pointed me to ffcal and I could find a way to solve my problem. But I'm still surprised by the fact this library is almost never used. Searching for reverse depends on the Debian archive, gnustep and gnustep libraries are the only packages to link against this library...

This made me think closure *is* a Cool Use For Perl...

daniel

Replies are listed 'Best First'.
Re: Closures
by imp (Priest) on Jul 19, 2006 at 23:45 UTC
    ffcal looks interesting, will have to play with it.

    It's surprising what languages support closures sometimes - like javascript

    Almost all of my javascript code these days uses try/catch and closures extensively.

Re: Closures are Easy in Perl
by CountZero (Bishop) on Jul 20, 2006 at 11:58 UTC
    Some might even say that closures are too easy in Perl and might happen when you least expect them. They are a well known "risk" if you switch your CGI-programs to mod_perl. Nothing that cannot be solved by careful programming, but if caught unaware it can really bite you.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law