Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101330 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4427 invoked from network); 12 Dec 2017 07:43:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2017 07:43:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; 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:51240] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/81-53433-0A88F2A5 for ; Tue, 12 Dec 2017 02:43:29 -0500 Received: from [10.42.251.33] (x52717921.dyn.telefonica.de [82.113.121.33]) by mail.experimentalworks.net (Postfix) with ESMTPSA id 49D276A482; Tue, 12 Dec 2017 08:43:25 +0100 (CET) Date: Tue, 12 Dec 2017 08:43:22 +0100 User-Agent: K-9 Mail for Android In-Reply-To: <274a646a-4e56-81fe-ac52-015da2bebc6f@gmail.com> References: <1512911576.12039.8.camel@schlueters.de> <274a646a-4e56-81fe-ac52-015da2bebc6f@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: Stanislav Malyshev ,Nikita Popov ,PHP internals Message-ID: Subject: Re: [PHP-DEV] [RFC] Explicit call-site send-by-ref syntax From: johannes@schlueters.de (=?ISO-8859-1?Q?Johannes_Schl=FCter?=) On December 12, 2017 7:38:54 AM GMT+01:00, Stanislav Malyshev wrote: >Hi! > >> I would rather discourage usage of references=2E Since PHP 7 the cost >of >> breaking cow isn't as expensive anymore, but receiving values by >value >> and returning by value is more idiomatic imo=2E Using objects can be >more >> efficient=2E > >Objects are kind of overkill when you just need a modifyable array=2E And >copying an array when you just need to add one value to a K-size array >is still not a good idea for many apps=2E O(n) vs O(n^2) still matters=2E >One should definitely be careful not to overuse refs, but there are >still valid cases for using them=2E The issue, as you well know, is that references disable copy-on-write=2E T= hus assume you have code like this: function with_ref(&$a) { count ($a); } function no_ref($a) { count($a); } The count in with_ref() will copy the array, while no_ref() can use copy o= n write and won't actually copy=2E johannes