Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37933 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29351 invoked from network); 28 May 2008 06:06:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 May 2008 06:06:07 -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:47495] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/50-15519-E46FC384 for ; Wed, 28 May 2008 02:06:07 -0400 Received: from [83.228.56.37] (port=3586 helo=pc) by host.fmethod.com with esmtpa (Exim 4.68) (envelope-from ) id 1K1EnT-0003O5-7r for internals@lists.php.net; Wed, 28 May 2008 01:06:03 -0500 Message-ID: <9E2672AD195F4FE4BC6CB68AF9A453FA@pc> To: References: <012701c8bb44$68f8b880$4401a8c0@foxbox> <48342DB7.2020108@isdg.net> <353f2c6f0805211141m9719d58xe0a128adbc14b656@mail.gmail.com> <353f2c6f0805211146p43d6aa96u9e6e03e82490b1c@mail.gmail.com> <325D72617BCF43A39670646B85FDB5FD@pc> <483BA7B1.2050008@zend.com> Date: Wed, 28 May 2008 09:05:56 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=response 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 are three purposes: 1) At call time, nothing significes what is the caller passing, the syntax is the same for passing reference or passing value, so it's prone to confusion. You're passing something which *may* or *may not* be modified if taken as a reference. Quick, is the variable taken by reference here somefunction($hi). A more clear version of the syntax is what I covered in my original email, where declaring function foo(& $foo) is a sort of contract that *forces* (with error) that the variable is passed by reference at call time, thus making the actions of the function explicit. 2) There's a broken symmetry here. While passing by reference is implicit at call time, at return time it's not. I need to both declare the function return by reference AND use "= & " to assign the results. Otherwise I get a copy. That's a problem I often have. There's no compiler error to warn me I did otherwise. I'd rather all those be explicit( require pass/return by val, require pass/return by refr: "&", accepts both "&?"), and the strict cases throw errors when the contract is not met at both sides. 3) As I mentioned there are three use cases, of which we support two, which I covered in my original email. The reason I said "in a perfect world" is because the current "hidden" pass by reference at call time will be incompatible with that scheme, so I doubt anyone would consider it. Regards, Stan Vassilev > Hi! > >> 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 > > I'm not sure I understand what's the purpose of this. Passing by reference > means that function may modify it's parameter. I see no reason why such > function should be called with some special syntax, could you explain? > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >