[gambit-list] Passing lambdas as callbacks to C functions

schemeway at sympatico.ca schemeway at sympatico.ca
Mon Feb 5 09:54:44 EST 2007


Phil,

>> I ran into problems using lambda expressions as callbacks when wrapping 
>> libcsv and I've boiled it down to this testcase. Can anybody tell me why 
>> this crashes?:
>...
>> looper is a c function which takes a scheme lambda and repeated invokes 
>> it using the 'call_lambda' bridging function.
>> 
>> When I gsc compile it and run '(main)' after a bunch of looping and 
>> printing it crashes with:
>> ERROR IN looper -- Operator is not a PROCEDURE
>> ('#<return #2>)
>> 
>> Any ideas?  (or am I being stupid?!)

> I'm just guessing here, but could it be that, since your lambda
> expression is not reference anywhere else in your Scheme code, it 
> gets GC'd?

I'm not so sure about my diagnostic anymore... I've able to reproduce your problem and it only shows up when started from the OS shell. If I first load your (compiled) code in gsi and then evaluate '(main)', I don't get the problem at all. 

That's strange... Marc, any idea?

Dominique




More information about the Gambit-list mailing list