rick2g has asked for the wisdom of the Perl Monks concerning the following question:
I've had to write a separate callback 'wrapper' for each function that I want to be able to call dynamically - but that means I have dozens of functions that look like this:$server_object->add_callback("function_name", "comma-separated-param_n +ames");
... and that's almost exactly the format for every callback - and I have dozens of those taking up lotsa text space and making what should be an elegant, concise file look incredibly bloated and copy/pasted. Is there anyway to dynamically generate these functions during compile-time so that I can just create an array with the callback/function names listed, then run thru the array to create the callbacks so that they can be loaded by the server during run-time?sub callback_wrapper { my ($callback_id, @params) = @_; my ($_err, $callback_data) = actual_function(@params); calback_reply($callback_id, $_err, $callback_data); return $_err; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dynamically generating function callbacks
by BrowserUk (Patriarch) on Nov 08, 2011 at 22:03 UTC | |
|
Re: Dynamically generating function callbacks
by graff (Chancellor) on Nov 09, 2011 at 08:17 UTC | |
by Anonymous Monk on Nov 09, 2011 at 08:59 UTC |