Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99323 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88237 invoked from network); 2 Jun 2017 14:57:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2017 14:57:04 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 84.19.169.162 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 84.19.169.162 mail.experimentalworks.net Received: from [84.19.169.162] ([84.19.169.162:52328] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/B7-12681-EBC71395 for ; Fri, 02 Jun 2017 10:57:02 -0400 Received: from kuechenschabe.fritz.box (ppp-46-244-161-171.dynamic.mnet-online.de [46.244.161.171]) by mail.experimentalworks.net (Postfix) with ESMTPSA id 6E3D656313; Fri, 2 Jun 2017 16:56:58 +0200 (CEST) Message-ID: <1496415412.4363.66.camel@schlueters.de> To: =?UTF-8?Q?Bart=C5=82omiej?= Krukowski , Dan Ackroyd Cc: "internals@lists.php.net" Date: Fri, 02 Jun 2017 16:56:52 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] RFC proposal From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Fr, 2017-06-02 at 15:21 +0200, Bartłomiej Krukowski wrote: > Hello, > > PHP allows for using implicit references in arguments of function. In > most common case we have to mark that variable is an reference in > head of function, in other case we will receive fatal error (@see > example - http://ideone.com/7zkgQQ ). There > is an option to use variable as implicit reference (@see example - ht > tp://ideone.com/T6oF7C ), I think it should > not be possible. Only explicit references should be allowed (except > objects). The argument to the function in the second value is an array which is passed by value. A copy of the array keeps the references as references. This is consistent. Unless we have typed arrays or anything like that the function call shouldn't care about the content. Aside from that references are a legacy construct and shouldn't be used anymore. Using objects or relying on copy-on-write usually leads to clearer code, reduced memory and faster execution. (in the past there had been a few exceptions where arrays of references were good for some graphs/trees with recent improvements to objects this is less the case) johannes http://schlueters.de/blog/archives/125-Do-not-use-PHP-references.html http://schlueters.de/blog/archives/141-References-and-foreach.html http://schlueters.de/blog/archives/180-References-Still-bad-in-PHP-7.ht ml http://schlueters.de/blog/archives/181-More-on-references.html