Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Richard Lynch
On Sun, May 7, 2006 1:20 pm, Chris Jenkinson wrote: > Currently I have a function which accepts a limited number of > parameters: > > call_function($function_name, &$var_1, &$var_2); > > I wish to modify the function to accept an indefinite number of > parameters, which may or may not be references

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Stut
Oops, returning the wrong thing. Corrected below... function call_function($function_name, &$vars) { $code = '$retval = '.$function.'('; $params = array(); foreach (array_keys($vars) as $key) $params[] = '$var['.$key.']'; $code .= implode(',', $params); $code .= ');'; eva

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Stut
Chris Jenkinson wrote: Currently I have a function which accepts a limited number of parameters: call_function($function_name, &$var_1, &$var_2); I wish to modify the function to accept an indefinite number of parameters, which may or may not be references. The function call_function() then

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Chris Jenkinson
Jochem Maas wrote: that smells like bad design (but then again you should see some of my code ;-) I blame PHP not allowing func_get_args() to use references, rather than bad design on my part. :) i can say with confidence 'no, your out of luck'. There must be some clever workaround u

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Chris Jenkinson
Tom Rogers wrote: Here is a cutdown version of a class loader I use, It works for php4 and php5 and with references. It should be easy to modify. [...] Sorry, this does not work with references as func_get_args() copies the arguments passed, rather than keeping them as references. This means

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-08 Thread Chris Jenkinson
Eric Butera wrote: One thing you could do is (assuming it's php4) [...] This is a bit of a pain though. :) Unfortunately, changing the functions to use &$params and using extract() is a significant API change and as such it would be a large amount of effort. Chris -- Chris Jenkinson [E

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Tom Rogers
Hi, Monday, May 8, 2006, 4:20:11 AM, you wrote: CJ> Hi, CJ> Currently I have a function which accepts a limited number of parameters: CJ> call_function($function_name, &$var_1, &$var_2); CJ> I wish to modify the function to accept an indefinite number of CJ> parameters, which may or may not be

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Eric Butera
On 5/7/06, Chris Jenkinson <[EMAIL PROTECTED]> wrote: Hi, Currently I have a function which accepts a limited number of parameters: call_function($function_name, &$var_1, &$var_2); I wish to modify the function to accept an indefinite number of parameters, which may or may not be references.

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Jochem Maas
Chris Jenkinson wrote: Jochem Maas wrote: although I wonder whether you shouldn't be re-evaluating what it is your trying to do because I get the impression it's a whole load of work for probably little payoff (consider that using alot of indirection in your code will make it harder to underst

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Chris Jenkinson
Jochem Maas wrote: although I wonder whether you shouldn't be re-evaluating what it is your trying to do because I get the impression it's a whole load of work for probably little payoff (consider that using alot of indirection in your code will make it harder to understand/read and therefore har

Re: [PHP] Passing an indefinite number of parameters by reference

2006-05-07 Thread Jochem Maas
Chris Jenkinson wrote: Hi, Currently I have a function which accepts a limited number of parameters: call_function($function_name, &$var_1, &$var_2); I wish to modify the function to accept an indefinite number of parameters, which may or may not be references. The function call_function()