Re: pass by reference variable length args

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

 



viraj wrote:
if func_get_args supports pass by reference, we could have avoid the
loop and pre-defined arg list.

something like..

extract(func_get_args)   :D

Absolute! I'm not sure why there isn't some kind of way to retrieve a reference in this manner, but I suspect it's related to knowing which parameters were set as reference appropriate values. For instance contrast the following:

    bind_stuff( $id, $test );

Versus the following:

    bind_stuff( 5, $test );

Defining the function parameters to use references will generate a fatal error when 5 is passed since this is a fatal error. How then to enable variable args to achieve the same result? I guess one could ask PHP to support something like the following:

    $args = func_bind_args( array( true, true ) );

Where $args would then contain a reference where the corresponding index was set to true in the argument list. Since this isn't very variable, then the last index set would denote the default for all other args. Thus the example above could be shortened:

    $args = func_bind_args( array( true ) );

Or even:

    $args = func_bind_args( true );

Since this is run-time too, then PHP could generate an E_WARNING instead of E_FATAL and bind a copy instead when no reference was passed.

On further thought, the current func_get_args() could be adapted in this manner since it currently accepts no arguments.

Anyways... just thoughts. I hit this problem in the past too :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
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