Re: Passing an indefinite number of parameters by reference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 harder to debug/maintain). why not consider the possibility that all these 'by reference' args could be items
in a single 'by reference' array?

Yes, that would be possible, however that would involve an API change - as now functions would have to get their variables out of an array rather than just a normal variable defined in the function. At the moment I've just decided to add more $var_x parameters.

btw: have you met call_user_func_array() yet? (not that it
would solve the problem because it doesn't 'do' references) - also,
it's manual page offers a hack for the reference problem your working on.

Yes, I briefly considered using it. Another method I tried was building a list of parameters and using eval() to call the function. Since I can't get the variables by reference, however, I've stuck with just passing $var_1, $var_2, etc. to the function.

Thanks for your comments. I think the amount of effort I would spend learning how to use the reflection API compared to just using a defined number of variables labelled in sequence is not worth it. If there was another way, perhaps...

Chris

--
Chris Jenkinson
chris@xxxxxxxxxxxxx

"Mistrust all in whom the impulse to punish is powerful."
 -- Friedrich Nietzsche, Thus Spoke Zarathustra

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux