From:             [EMAIL PROTECTED]
Operating system: Any
PHP version:      4.0.5
PHP Bug Type:     Feature/Change Request
Bug description:  function enhancements

Hi, I have a few ideas for enhancements to PHP's functions that would make them much 
more powerful.  

First, when using variable length argument lists (using func_get_arg, etc.) there 
should be a way to treat these as references.  As of now, it seems to me that only 
pass by value can be achieved with this mechanism.  A simple func_set_arg function 
would fill this gap nicely.

Second, macros would be a nice addition.

Third, and most important I believe, there needs to be a mechanism for inheriting 
scope in a function - rather than choosing between the extremes of global and local.  
For instance, the following code demonstrates my point:

function a() {
   global $var;
   $var = 10;

function b() {
   $var = 5;
   print $var; # still prints 5 because a()'s $var is global
               # whereas b()'s var is local.  There is NO
               # way to reference b()'s var in a() as it
               # stands - the only way to do it would be to
               # make a() get passed a reference to $var

$var = 5;
print $var; # here, however, everything works fine because
            # the $var here is global

The behavior of a() here is, if not downright inconsistent, somewhat frustrating.  
Now, consider if we had an inherit construct, which inherited the variable from the 
calling scope.  If a() then was defined as

function a() {
   inherit $a;
   $a = 10;

the behavior would be more consistent to what the writer of function b() intended.

With these additions, I think a lot more could be accomplished with functions.

Thanks for a great product,
Robby Walker

Edit Bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to