Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99328 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99796 invoked from network); 2 Jun 2017 17:36:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2017 17:36:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.174 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.128.174 mail-wr0-f174.google.com Received: from [209.85.128.174] ([209.85.128.174:36414] helo=mail-wr0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/89-12681-A32A1395 for ; Fri, 02 Jun 2017 13:36:59 -0400 Received: by mail-wr0-f174.google.com with SMTP id v111so3833744wrc.3 for ; Fri, 02 Jun 2017 10:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=6C/4yIJGShltOgHEVz4K9X1e1n4ck0SyJxcSu7R7EDI=; b=TSJ8frL16BjjBE25GaG3anis+u1zNR5hTCQVeUFBtQW/3B1AjzClYarCETCdL2pnl2 q6mjbtLh6SFqc49/tknplWQjETC/2IwlkWwhHzYnQpSrInfqO6wE3WRNTQ+PESzcqq+v 8UH4EOw83hCStnakXvuozeP2JymaaSIyDSttDx66SnWpaij4jJm+GDPGVFQBN5yjR8Ze d+p7lQBm9PYJXLojsLNGjAVpuew3eoTCC0C8rXXcvKuziYog4D/zcXBsLEGmUWThz4xf wvf7mpq6E3jaOwu4LXVvUc9X0ycNpliPbYCjqXvPgYxVk3Q7xUaMDULAnE49ScV2d//U xOJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=6C/4yIJGShltOgHEVz4K9X1e1n4ck0SyJxcSu7R7EDI=; b=oR9CVadZf0epgt3jUP1wYEyOEERrun7mpmHnUj5dVRM2/BbeQ9Lc0X/Ch5WBoptafm yaYsojBEhA0zH64F0bs3NFwcr4x24bbhaYIvWnTIqne4tQHJnxXNlNguOcwaep7aXdD4 /cUber+o+AfvkP0KyJh6xFm+jqIEVV5Atdu770abaG9kaUWdx1ErEFPEfwjjLykN1Lwa N4TO9ZTq0xE96/LHSafLG6u4NpC46Ht/BLvfx+FLA1wA/F6w7R2DmuUvs+qE/68szPjC AuuScDiFJ2oyiwb55BvORgPCqQKSQa232tw+jmbt2Ld7t6sHPQH9FAQE1vcMQIqowiFc g6mQ== X-Gm-Message-State: AODbwcBC8BqY4DM3Vl/ze7uYW3BPtflp9SqMdzwIPJl+lKzeZL0Ww8tB GpPEivq6deqmri10zDE= X-Received: by 10.223.129.6 with SMTP id 6mr1496331wrm.104.1496425015351; Fri, 02 Jun 2017 10:36:55 -0700 (PDT) Received: from [10.7.17.11] (188.29.165.251.threembb.co.uk. [188.29.165.251]) by smtp.gmail.com with ESMTPSA id x37sm40666285wrb.42.2017.06.02.10.36.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 10:36:54 -0700 (PDT) Date: Fri, 02 Jun 2017 18:36:51 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <1496415412.4363.66.camel@schlueters.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: <3A1C5448-F0A0-481E-8B42-3C47E5D6AB64@gmail.com> Subject: Re: [PHP-DEV] RFC proposal From: rowan.collins@gmail.com (Rowan Collins) On 2 June 2017 18:21:34 BST, Levi Morrison wrote: >On Fri, Jun 2, 2017 at 11:12 AM, Michael Morris >wrote: >> What about foreach by reference, which is honestly the only time I >use >> referencing anymore=2E=2E=2E >> >> foreach ($array as $key =3D> &$value) { >> $value =3D someOp($value); >> } >> >> Is this also bad? > >I'm not going to say "bad" but I would not personally write it that >way=2E If the memory cost is too high to duplicate then =2E=2E=2E The times I've used foreach-by-reference have absolutely nothing to do wit= h memory cost=2E Mostly, they're situations where explicitly writing back i= nto the original array would be tediously long-winded, like this: $some_array[$some_outer_key][$loop_key]['foo'] =3D some_func($loop_value['= foo']); $some_array[$some_outer_key][$loop_key]['bar'] =3D some_other_func($loop_v= alue['bar'], true); Granted, there are probably major refactorings that would be in some way b= etter, but changing $loop_value to a reference gives the much more readable= : $loop_value['foo'] =3D some_func($loop_value['foo']); $loop_value['bar'] =3D some_other_func($loop_value['bar'], true); References are fiddly, but they do have their uses=2E Short of eliminating= mutability, per functional programming, I think they'll always have their = place, in some form=2E Regards, --=20 Rowan Collins [IMSoP]