Is there any utility function in Pike that does the following, or an approximate?
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; werror(master()->describe_backtrace(err)); }
...preferably with typechecking.
I find that I would like to put a wrapper around my callbacks a lot of the time, to be certain that the code following still is run even if the user (of my library-ish routines) makes an error.
Not that I know of. Should fit fine in Function.pmod if you care to implement it.
/ Martin Nilsson (saturator)
Previous text:
2003-12-08 10:24: Subject: call_callback
Is there any utility function in Pike that does the following, or an approximate?
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; werror(master()->describe_backtrace(err)); }
...preferably with typechecking.
I find that I would like to put a wrapper around my callbacks a lot of the time, to be certain that the code following still is run even if the user (of my library-ish routines) makes an error.
/ Mirar
Is it really worthwhile? It's only two lines of code and the error handling will probably be different for most implementations anyway.
/ Jonas Walldén
Previous text:
2003-12-08 11:03: Subject: call_callback
Not that I know of. Should fit fine in Function.pmod if you care to implement it.
/ Martin Nilsson (saturator)
It's the same error handling you get for for instance read callbacks.
/ Mirar
Previous text:
2003-12-08 11:13: Subject: call_callback
Is it really worthwhile? It's only two lines of code and the error handling will probably be different for most implementations anyway.
/ Jonas Walldén
If you think really hard you can probably do a type checker by applying _typeof on f and the args.
/ Martin Nilsson (saturator)
Previous text:
2003-12-08 11:13: Subject: call_callback
Is it really worthwhile? It's only two lines of code and the error handling will probably be different for most implementations anyway.
/ Jonas Walldén
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; werror(master()->describe_backtrace(err)); }
You should probably use master()->handle_error() instead:
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; if (err) master()->handle_error(err); }
/ Henrik Grubbström (Lysator)
Previous text:
2003-12-08 10:24: Subject: call_callback
Is there any utility function in Pike that does the following, or an approximate?
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; werror(master()->describe_backtrace(err)); }
...preferably with typechecking.
I find that I would like to put a wrapper around my callbacks a lot of the time, to be certain that the code following still is run even if the user (of my library-ish routines) makes an error.
/ Mirar
Most probable. I'll put that code into Functions.
Is there any way to get type checking from args on f?
/ Mirar
Previous text:
2003-12-08 11:28: Subject: call_callback
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; werror(master()->describe_backtrace(err)); }
You should probably use master()->handle_error() instead:
void call_callback(function f,mixed ... args) { mixed err; err=catch { f(@args); return; }; if (err) master()->handle_error(err); }
/ Henrik Grubbström (Lysator)
pike-devel@lists.lysator.liu.se