Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79453 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8881 invoked from network); 6 Dec 2014 08:52:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2014 08:52:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@bof.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: php@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:34373] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/10-06932-7E3C2845 for ; Sat, 06 Dec 2014 03:52:57 -0500 Received: (qmail 6498 invoked by uid 1009); 6 Dec 2014 09:52:52 +0100 Received: from 209.85.216.53 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/19739. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.216.53):. Processed in 0.269165 secs); 06 Dec 2014 08:52:52 -0000 X-Antivirus-MYDOMAIN-Mail-From: php@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.216.53):. Processed in 0.269165 secs Process 6475) Received: from mail-qa0-f53.google.com (gmail@bof.de@209.85.216.53) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 6 Dec 2014 09:52:52 +0100 Received: by mail-qa0-f53.google.com with SMTP id bm13so1508418qab.12 for ; Sat, 06 Dec 2014 00:52:50 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.172.131 with SMTP id l3mr33847570qaz.32.1417855970307; Sat, 06 Dec 2014 00:52:50 -0800 (PST) Received: by 10.140.37.41 with HTTP; Sat, 6 Dec 2014 00:52:50 -0800 (PST) Received: by 10.140.37.41 with HTTP; Sat, 6 Dec 2014 00:52:50 -0800 (PST) In-Reply-To: References: <2D560BB1-318F-461F-96CD-BE25C346E14F@gmail.com> Date: Sat, 6 Dec 2014 09:52:50 +0100 Message-ID: To: Yasuo Ohgaki Cc: internals , Rowan Collins Content-Type: multipart/alternative; boundary=047d7b673fb673f8e605098851b1 Subject: Re: [PHP-DEV] Re: Only variables can be passed by reference From: php@bof.de (Patrick Schaaf) --047d7b673fb673f8e605098851b1 Content-Type: text/plain; charset=UTF-8 Am 06.12.2014 04:04 schrieb "Yasuo Ohgaki" : > > $top = array_pop(f2()); > > is better than > > $v = f2(); > $top = array_pop($v); > > Is there anyone who likes latter? It is bad practise either way, having poor f2() build up a whole array that is then immediately thrown away. The second case is worse due to missing an unset($v), keeping the array around for eternity... I personally do find it annoying to "need" a variable there, just because the outer called function happens to take a parameter as reference - which is not visible at the calling place at first glance, thus making me wonder, when only looking there, what the hell that scratch variable is supposed to accomplish... In practise this part of the issue didn't arise that often, compared to the other part: only being able to return variables by reference. Concretely, that hit me when writing return-by-reference offsetGet() methods that sometimes need to return null. Not that bad, in a sense, because the scratch-null-holding-variable is contained in the place where it belongs, the offsetGet method itself - but nevertheless strange... best regards Patrick --047d7b673fb673f8e605098851b1--