Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99852 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54766 invoked from network); 12 Jul 2017 12:06:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2017 12:06:35 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.171 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.171 mail-wr0-f171.google.com Received: from [209.85.128.171] ([209.85.128.171:36156] helo=mail-wr0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/B4-01782-2C016695 for ; Wed, 12 Jul 2017 08:06:28 -0400 Received: by mail-wr0-f171.google.com with SMTP id c11so30756544wrc.3 for ; Wed, 12 Jul 2017 05:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=B1433JIoDViVn6Qhk9H17wDVE9yHaL7MZyxgN21cN7g=; b=mXuIKX1D319CgGDgCx0F4x1Dy29Py7rDY59qL3Fpv/Smn8DTT63h8AFItJboq5iroh 1AGL3ohwDR1/aYF87aphm4loke+xz+bb/25rG4XwFW1tY9uircFvrtbnY/MsPl1Kwy6u utNfyM1npiNAFJxoK8IGdOyEBe3TtzuoLjZsIXyf4221ynzhOKtRDwUoryo99KfKZl52 hwcjRjphFx/7YtWt2ov3Z0tpiQUB2uIT/akK8/isoTdVxbLSjhhX1b4oXKYa4a0OapFP A4Kb5t7xBCF7DMn1t0s+1AirmOA6JxRSlFDJW+wlL2tZU0W03HMEfvcAkbw8njB+jrxq K8/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=B1433JIoDViVn6Qhk9H17wDVE9yHaL7MZyxgN21cN7g=; b=ucVbOX4RAWYKOfHZKP01fzCmUqFv1oE4ZhbPj+hi4IZcKp2WtDv4rbH88QVAxxhJ7r TG+5mx0Faglir+bf0F0JDJ7kym5aL5sD0q3kOHEUuWA/hfnSavnaLsj4q5E/7VGpOy86 jcLlrwjPi7DCAWCrQS+Db2vtjedRDMVTxyWHwrOl4j9dwBU/+FRNS0aT5k8JjbSGoi0+ fNkrlxfLJtT1MDMbUDD9rbqh1W9uk6m+jlPDCDq49EUFUy7fM0EdXDb71/5lHGVARkEa NoTlUb7ZVNMxgTzW+oSzoO0y08YQHQiZVdxHY4OLdq3Ja+pQ8HiwyeptgqUEL0r/1ouQ vEug== X-Gm-Message-State: AIVw111ByglKGaPueYm3N4blInJWe2lLwEklAnrz3jjZy+KCmGFzOZff rFSWq9KymQjW+cUMLpG9lznOoZWPKg== X-Received: by 10.28.152.141 with SMTP id a135mr2454966wme.39.1499861184083; Wed, 12 Jul 2017 05:06:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.161.155 with HTTP; Wed, 12 Jul 2017 05:06:03 -0700 (PDT) In-Reply-To: References: Date: Wed, 12 Jul 2017 14:06:03 +0200 Message-ID: To: =?UTF-8?Q?Bart=C5=82omiej_Krukowski?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="001a114b2fbc1700f605541da53b" Subject: Re: [PHP-DEV] RFC proposal - unpack iterator From: ocramius@gmail.com (Marco Pivetta) --001a114b2fbc1700f605541da53b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 12, 2017 at 11:22 AM, Bart=C5=82omiej Krukowski < krukowski.bartlomiej@gmail.com> wrote: > Hello, > From PHP 5.6 we have possibility to add variadic functions and unpacking > arrays via *...* > Would be nice to extend responsibility of *...*. Sometimes in code I can > find lines similar to the following: > > $result =3D array_merge(['some value'], ['some other value'], $array); > > > I would like to shorten this line to the following: > > $result =3D ['some value', ['some other value'], ...$array]; > > > And even allow to unpack more than one array: > > $result =3D ['some value', ['some other value'], ...$array, ...$secondArr= ay]; > > > Using new operator we can produce shorter and more clearable code. I woul= d > like to create RFC for my proposal. If you think idea can be useful, plea= se > give me an access for creating RFC. > > Best regards > Would this allow operations such as the following one? $a =3D [0]; $b =3D [1]; $otherArrays =3D [[2,3], [4,5]]; $mergeAll =3D [...$a, ...$b, ...[...$otherArrays]]; // [0, 1, 2, 3, 4, 5] Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a114b2fbc1700f605541da53b--