Re: RFC: allow_call_pass_by_reference

From: Date: Thu, 22 May 2008 09:08:47 +0000
Subject: Re: RFC: allow_call_pass_by_reference
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-37791@lists.php.net to get a copy of this message
Hi, There is a use case for the function allowing *explicitly* call-time pass by reference, because the function works both ways in subtly different ways. I have some libraries where I had to have variations of the functions like "AbcByRefr()" and "Abc()", because of this inflexibility. In a perfect world, here's how I'd do it, of course the actual syntax can be something else (this also improves the understanding of the code as it makes the intent explicit, versus implicit at call time, as it is now): --- function foo(& $a) {} // allows only explicit pass by reference foo($a); // illegal, error foo(& $a); // legal, pass by reference --- function bar($a) {} // forbids pass by reference foo($a); // legal, pass as 'copy' foo(& $a); // illegal, error --- function baz(&? $a) {} // acknowledges that it functions properly and accepts both ways foo($a); // legal, pass as 'copy' foo(& $a); // legal, pass as reference --- Regards, Stan Vassilev
On Wed, May 21, 2008 at 10:46 PM, LEW21 <lew21st@gmail.com> wrote:
Sometimes call time pass by reference is useful, for example when you want to make it possible to omit an param (normally passed by reference) by setting null. With no call time pass by reference, programmers are required to write: $null = null; foo($null);
what stops you from declaring: function someFunc(&$param = null) { } it works just fine
Deleting it isn't a good idea, it should become a normal (not deprecated) language feature.
-- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#37791) next »