Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103477 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55671 invoked from network); 22 Nov 2018 09:24:43 -0000 Received: from unknown (HELO mail-lf1-f52.google.com) (209.85.167.52) by pb1.pair.com with SMTP; 22 Nov 2018 09:24:43 -0000 Received: by mail-lf1-f52.google.com with SMTP id e26so5664079lfc.2 for ; Wed, 21 Nov 2018 21:47:01 -0800 (PST) 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=cHFurL4ktm1up4QrFLwOgmVQWTB1pfKBrKk3eERnVKs=; b=iDdIweyd9kix+XwoyjcPz07wDG7IhVa+B+QDl75I1qsHKnI/TrN1c4OuhLhTO/GK3k 4FOhf2BM/f+6MGup4kL7Wf22k8OG+mb29FfLCQFTorH3NnHl9UAl2ayPAiCPFo/6FTvc s1l48yZ+2jtobZ1LgiPODivYs6vfPBnqwlnhsQOSJ5RzghxZgJHviMngK3POLl98r+a5 yuxy5u0BQNz8FrNafj0l9KCNKCK9M3zRUYPcM1F2UCKc1dpZSU5KJbYoEGRg3Tw07IOn 5dXBSIgFusCooBrkL/J2sShwQHW2r950x7EyZfw81i4CmQ9iSvs5vPAE7rlVZU0N7tOs utig== X-Gm-Message-State: AGRZ1gKWNNfe6SvHgM+3w9Hw/sR7lyHsjyvVLzqD22D4sgT9R6IUCa9P qIPdLG6cKUqw81nrt3irfHmbDukeGagFXm8l2vg= X-Google-Smtp-Source: AJdET5dmEalMz12IZouuCk4yW8vvKiLkGs5GYpq/TyG5bLrNGkBFyFMdQR4Afq+bOh/TV08O5Z0m/hS2z+4PWbn/aL0= X-Received: by 2002:ac2:4215:: with SMTP id y21mr5440660lfh.6.1542865620268; Wed, 21 Nov 2018 21:47:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 21 Nov 2018 22:46:42 -0700 Message-ID: To: Nikita Popov Cc: me@jhdxr.com, internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Spread Operator in Array Expression From: levim@php.net (Levi Morrison) On Wed, Nov 21, 2018 at 12:31 PM Nikita Popov wrote: > > On Mon, Nov 19, 2018 at 9:26 AM CHU Zhaowei wrote: > > > Hi internals, > > > > I'd like to start the discussion for [RFC: Spread Operator in Array > > Expression](https://wiki.php.net/rfc/spread_operator_for_array). In > > short, this is a syntax similar to argument unpacking, but for array. > > > > You can find the implementation [here]( > > https://github.com/php/php-src/pull/3640). It's still WIP, but I'll > > finish it in the next following weeks. > > > This looks reasonable to me. The array_merge() behavior is certainly the > one I would (in PHP) expect intuitively, and it is likely the most useful > one as well, striking a balance between behavior useful for pure vectors > and pure dictionaries (and falling short if it's not either ... as is usual > in PHP). > > Nikita I think we have `+` and `array_merge` already. What we *don't* have is something that concatenates solely with values and ignores keys, at least not in a single step. I think `...` can be that operator, precisely because this is what it does for function calls as well. In other words, this results in a completely sequentially ordered array, regardless of the key structure of `$rest`, and does not overwrite positions 0 and 1: $data = [$first, $second, ...$rest]; Those are the semantics that I would like. I think `+` and `array_merge` serve the other cases, so no need to deviate from how this works with function calls, which are obviously positional and will not overwrite previous values.