Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99327 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98097 invoked from network); 2 Jun 2017 17:21:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2017 17:21:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.54 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.54 mail-it0-f54.google.com Received: from [209.85.214.54] ([209.85.214.54:38249] helo=mail-it0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 77/39-12681-1AE91395 for ; Fri, 02 Jun 2017 13:21:37 -0400 Received: by mail-it0-f54.google.com with SMTP id r63so25389118itc.1 for ; Fri, 02 Jun 2017 10:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=3rZTCHKoc52KwYilfn7CgERFqTPfjps5Ks5RdJau0Xk=; b=HVi0ohPalYlIa/0XavhgO7ZWD1EVKMGb9gcYYuIFGBhQFSThhRoFkm1DfdunbkxmJ5 VBCWDHqKzCc9298UQ9w/qTKmtFCBilibcRy/4c+R8gFXQ6i7c+ls4N2pyXzXKtp1BrPE pTRBolaH8pkN/oN6mSnFRLogAnnjjnBRTUcDPEl0c6qoHWETh+blz4+AIy6WeBuQda+j sGO+s/JwRtlKQKBAR6R3xw/2cloLRh4HNKwBKwqJYn+UEjhiv3GW01BwN3vifEsljy0f qhARac7IsgDAKvD6V8OWPffWzk7T6W008RhBawPWRAyWQB3zE0tQBjF30v021RGzUF2g mh8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=3rZTCHKoc52KwYilfn7CgERFqTPfjps5Ks5RdJau0Xk=; b=os5rpdGSCpTKmudZp7Q7ws9NxN5Tx1wHfNPaRT6ZOO2exZ6lRp4MyLv9IjOOfNgRNf Nb/6vyG5Sx4qHyPpQjEcXmnOsAnYXMjOMpgcaWtf8C33lGqLByXesXxQLwVOZPiLaWwO 9rnSKa9pod61xu9Xa27ZkICca4WqBaXBa5w4iHurFSio3YCKjTqlpWWlxOLLcr9Ny6wW wCfn1ww4fE3jkEH/SoC3l1VfheAwG688f7Yf0AYenG1KAgMM476l2Nx4mn41vcVJUZc0 sh62rGlTiuyfK8f7LwMOCey8yZn65YY8vJ7IRGr2etLj7XdlVjkCbJqLcFrsML5VSD+e XQew== X-Gm-Message-State: AODbwcC2tAEx+vDbFuCmIaQsn+4qlYfc5aaOGOwvvd3lQbztkbRe3100 2wt3HvkV2qjcS5jHMr+d3hCVivZ/9Q== X-Received: by 10.36.147.2 with SMTP id y2mr404134itd.43.1496424095029; Fri, 02 Jun 2017 10:21:35 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.107.12.159 with HTTP; Fri, 2 Jun 2017 10:21:34 -0700 (PDT) In-Reply-To: References: <1496415412.4363.66.camel@schlueters.de> Date: Fri, 2 Jun 2017 11:21:34 -0600 X-Google-Sender-Auth: QL4KnKTqBipsBRP6bGZdx_6MbOM Message-ID: To: Michael Morris Cc: "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] RFC proposal From: levim@php.net (Levi Morrison) 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... > > foreach ($array as $key => &$value) { > $value = someOp($value); > } > > Is this also bad? I'm not going to say "bad" but I would not personally write it that way. If the memory cost is too high to duplicate then I'd use a generator that maps the value; I have this function in all my projects because it's fairly common anyway: function (callable $fn, iterable $input) { foreach ($input as $key => $value) { yield $iey => $fn($value); } }