I've tried, but either I'm doing something wrong, or it doesn't work. I think the destructed test is not that easily fooled. It seems to be this code that checks if a call_out is destructed:
check_destructed(Pike_sp - args); if(TYPEOF(Pike_sp[-args]) != T_INT)
It seems hard for any type of lambda or object to pass that test...
Anyhow, you have convinced me that my naive extension of Function.curry is a bad idea. If the curry object could be destructed, that would be nice, but I don't see how that can be implemented without a major effort.
For my application, it is easy enough to do like this:
function(mixed...:mixed) if_living(function(mixed...:mixed) f) { return lambda(mixed ...args) { return f && f(@args); }; }
And use it like:
Function.curry(if_living(some_method))(1, 2, 3)
instead of:
Function.curry(some_method)(1, 2, 3)
You just have to ensure that it is OK to return 0 if f is dead.