Re: Passing an indefinite number of parameters by reference
| From: | Chris Jenkinson | Date: | Sun, 07 May 2006 19:14:14 +0000 |
| Subject: | Re: Passing an indefinite number of parameters by reference | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235693@lists.php.net to get a copy of this message | ||
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@starglade.org "Mistrust all in whom the impulse to punish is powerful." -- Friedrich Nietzsche, Thus Spoke Zarathustra