Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105081 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38201 invoked from network); 4 Apr 2019 19:44:04 -0000 Received: from unknown (HELO mail-it1-f174.google.com) (209.85.166.174) by pb1.pair.com with SMTP; 4 Apr 2019 19:44:04 -0000 Received: by mail-it1-f174.google.com with SMTP id w15so4775497itc.0 for ; Thu, 04 Apr 2019 09:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dl34cZ+MkUZBacs7kDBgnX3om4zlDBRu8oKEB+N3FFA=; b=eoSOTYtZC9lXhLFlvgdh7nafTLTwhHSiuYSdEf4q9YzrZH3LEP51SR4iK+OQ6ll+iT i1mIV5Z2JBrHDHEHRkC7L6vX12MmMl3ZpxelYDZQ3lqxEx76SFjfcy9tLA86nWrtWhzN x2FjHA0OQ0LxZ8aN/+eljc1AkftpUoUM+21KmIJd+QMNXWDex6+woPxTQP/RJHr9tZnu AlDmzmTGlyBSjZ5nfYVYHY3/T5w09e7XgtIZs/A5mh3HSiR5YpjMCAS8Ff64hl+PejMb 9XcR8ow6DcpYmknPa4uGAHRDKE31DVQ5AJsTp5wgY5RMocJhz+ElKO92vx6/j18Yd568 JnLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dl34cZ+MkUZBacs7kDBgnX3om4zlDBRu8oKEB+N3FFA=; b=Ubz1Wub4NCJFQSGYP2evvH4ljWSh7fgq7QSXX6r7TcglDrJFiLTRRMYSoF5HXm6ybJ IJJ2oZxL8wmqoRhIwiCmXQmgGJ9z1nrx015Ur6CR2NDu0HY92QtKq7q5n3cbErCsk7Z+ aXoqtFLStiVA4VgqgjgsbGT5AFsszPsNLqjB3jhFjkZIOOKFAGyrh1PyQCX4Ubfk6SoJ T9mfMRQGlUQ5S+nEpKkk/KMDYPMBmFFCmmrlDqUi5eRS9ZCBJhBnqI5UD/ZoE2odQjRo YtYVJ9cDlWI1p5583L7oRq9yfc3HE8F2px9lyR5cvbI6S1Ng6n5elPEGWE1A7VjXL6Uz W0yw== X-Gm-Message-State: APjAAAWcDnL/FHoGep9C3NUo5qFWm4BtMJzpyeXMIAYnwIabTIe/IyIc fes4Ze+di2s1qeU99j4AfpwrcvecVt2RjDwaPHzSBVYJ X-Google-Smtp-Source: APXvYqw+PgPZAGPqSgXK5ti4IwBzfbc6gj7ashnNrSln0Hay6eA2tkfssAJ9EM8VM9ZPeKRsSZCVjFXrcNkVqSsVbMU= X-Received: by 2002:a02:a58e:: with SMTP id b14mr5654754jam.77.1554395984790; Thu, 04 Apr 2019 09:39:44 -0700 (PDT) MIME-Version: 1.0 References: <003a01d4eaf0$c17d6c20$44784460$@jhdxr.com> In-Reply-To: Date: Thu, 4 Apr 2019 17:39:33 +0100 Message-ID: To: Derick Rethans Cc: CHU Zhaowei , PHP internals Content-Type: multipart/alternative; boundary="000000000000838bbe0585b70485" Subject: Re: [PHP-DEV] [RFC] Spread Operator in Array Expression v0.2 From: rowan.collins@gmail.com (Rowan Collins) --000000000000838bbe0585b70485 Content-Type: text/plain; charset="UTF-8" On Thu, 4 Apr 2019 at 17:14, Derick Rethans wrote: > Could you add to the RFC what the exact pain point is that this is > trying to address? It looks a little like this is just adding syntax for > the sake of it. > Not everything is about pain, some things are just about gain. ;) The link Levi shared about Dart included some interesting examples of where spreads are useful, some of which you can probably imagine happening in PHP: https://medium.com/dartlang/making-dart-a-better-language-for-ui-f1ccaf9f546c It also takes us a step closer to having a short-hand for iterator_to_array, in the shape of [...$iterator]. On its own, that's still pretty ugly, but it's not hard to come up with cases where it would be a lot nicer, like concatenating two iterators: // Before array_merge(iterator_to_array($iter1), iterator_to_array($iter2)) // Or to generalise to all iterables array_merge( is_array($iter1) ? $iter1 : iterator_to_array($iter1), is_array($iter2) ? $iter2 : iterator_to_array($iter2) ) // After (handles both cases) [ ...$iter1, ...$iter2 ] Granted, I can't point to a real-life example of that, but it shows that this isn't just new syntax for something that's already easy. Regards, -- Rowan Collins [IMSoP] --000000000000838bbe0585b70485--