Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Closures are Easy in Perl

by ruoso (Curate)
on Jul 19, 2006 at 21:53 UTC ( #562451=CUFP: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://562451]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2020-12-05 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?