Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37791 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73289 invoked from network); 22 May 2008 09:09:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 May 2008 09:09:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:47618] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/83-53818-C2835384 for ; Thu, 22 May 2008 05:09:01 -0400 Received: from [83.228.56.37] (port=3508 helo=pc) by host.fmethod.com with esmtpa (Exim 4.68) (envelope-from ) id 1Jz6nB-0005KY-65 for internals@lists.php.net; Thu, 22 May 2008 04:08:57 -0500 Message-ID: <325D72617BCF43A39670646B85FDB5FD@pc> To: References: <012701c8bb44$68f8b880$4401a8c0@foxbox> <48342DB7.2020108@isdg.net> <353f2c6f0805211141m9719d58xe0a128adbc14b656@mail.gmail.com> <353f2c6f0805211146p43d6aa96u9e6e03e82490b1c@mail.gmail.com> Date: Thu, 22 May 2008 12:08:47 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] RFC: allow_call_pass_by_reference From: sv_forums@fmethod.com ("Stan Vassilev | FM") 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 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 >