Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99854 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57605 invoked from network); 12 Jul 2017 12:12:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2017 12:12:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.181 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.181 mail-wr0-f181.google.com Received: from [209.85.128.181] ([209.85.128.181:35698] helo=mail-wr0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/55-01782-44216695 for ; Wed, 12 Jul 2017 08:12:52 -0400 Received: by mail-wr0-f181.google.com with SMTP id k67so30967997wrc.2 for ; Wed, 12 Jul 2017 05:12:52 -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=CMqk5ixuX7/oVOFPVtH08gTIe2e2wp8mfQeDaeHHNqo=; b=AZrnS7buoR5sasJsfPwy0OYf2/axS2zq1zfE3EelVNubqA2ArBbIBKaIcAU2cZEnSd 0qRdTPa3KG4ByaSqhuvM6RL+Pw5YSJwdRCwU1Wymin1MG2hWdl0QGGNGi7S/hUTHMcH8 ESoHHY4rMpUv/3cpoVXsldFbH+6/wI/xiTYlsSQITChpmaXy8bEojccW0VlEEMDnVVkn AtOpgXdE7kH0rvXAmFhCmndzrJHvjuNOexhbFkQDivZ47XBZb9f1JtA+UaYzb5Rb/h8Q t9/UOJIX+7vwYqiqWldDT/GNi2JEJ6nzCmIXMxwNFi7SPxem1SrzLpcps1GJZNd3NVL1 jKug== 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=CMqk5ixuX7/oVOFPVtH08gTIe2e2wp8mfQeDaeHHNqo=; b=XOuPsHT7ajgYPGWfN2xUcmc5WKjQYAF5d6lxpxtTqUiUayE8Le8tkOtq5vn4cKzrSD opERd3INmVbCag1uuE0f50GjoVqpbYZ4BBjQH2H7Ry4KfZoQJjFLkvd+OlqvgA79PTqt DsxqLEXNYqcImXDJj6YQRPIsGmkBY0rCUTowrVhGD2GOrg0c8iKrC58A3+w1MX0eqLpF a2xwwj5uCScTzZK+Q/lXFuU4fe+NWCGX0uRS5rvoqwfxZ5QKn2NNglpic56YwnqLXZ0y 7SKBZWgPobdJ/BZ53IWlBY99bN9W2CISN+Fx9LoeXz1n0xj/vYDfihIkOzetbmmImZaU YfTw== X-Gm-Message-State: AIVw1129MjTJ/mkB/8ARe+PB76Fq+1iUvcszDQWd6Y87gNM/3yjArP+l zORVuiIaJRJBFmPSP2uwFRuYkoPHEA== X-Received: by 10.28.29.9 with SMTP id d9mr2465451wmd.39.1499861569149; Wed, 12 Jul 2017 05:12:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.161.155 with HTTP; Wed, 12 Jul 2017 05:12:28 -0700 (PDT) In-Reply-To: References: Date: Wed, 12 Jul 2017 14:12:28 +0200 Message-ID: To: =?UTF-8?Q?Bart=C5=82omiej_Krukowski?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="001a114b7a1c0aa53805541dbc37" Subject: Re: [PHP-DEV] RFC proposal - unpack iterator From: ocramius@gmail.com (Marco Pivetta) --001a114b7a1c0aa53805541dbc37 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 12, 2017 at 2:09 PM, Bart=C5=82omiej Krukowski < krukowski.bartlomiej@gmail.com> wrote: > Hello, > > Yes, this is exactly what I would like to achieve. > > Best regards > > 2017-07-12 14:06 GMT+02:00 Marco Pivetta : > >> 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 unpackin= g >>> arrays via *...* >>> Would be nice to extend responsibility of *...*. Sometimes in code I ca= n >>> 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, >>> ...$secondArray]; >>> >>> >>> Using new operator we can produce shorter and more clearable code. I >>> would >>> like to create RFC for my proposal. If you think idea can be useful, >>> please >>> 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/ >> >> >> > TBH, I'd like to have a functional approach to this, so that I can use functional composition instead of operators (`array_map('...', $values))`). Still, the addition is very nice and complimentary with the existing splat/variadic argument stuff :D Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a114b7a1c0aa53805541dbc37--