# The following was supposedly scribed by
# [EMAIL PROTECTED]
# on Thursday 10 March 2005 09:04 am:

>In my understanding, Perl functions have no analogous C function
> behind the scenes.

Even worse, aren't C function pointers fixed as of compile time?

>If you need to pass a function argument to some external function, you
> should probably use a wrapper.

Would that require you to set a global variable in your C code?  Such as 
the below (poorly written) pseudocode, where the callback is to a pure 
C function that gets the Perl subroutine from a hardcoded variable.  

Something like:
// I'm just making stuff up here, some syntax may be incorrect.
SV* mysub;

void callback_wrap(myCallback) {
  // error checking, etc
  call_sv(mysub);
}

void perl_method(SV* callback) {
  // callback doesn't exist until runtime
  mysub = callback;
  // callback_wrap has been at one memory address since compiling
  some_C_method(callback_wrap);
  mysub = SV_NULL; // or something
}

--Eric
-- 
"Matter will be damaged in direct proportion to its value." 
                                        -- Murphy's Constant
---------------------------------------------
    http://scratchcomputing.com
---------------------------------------------

Reply via email to