Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78846 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54854 invoked from network); 7 Nov 2014 17:19:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2014 17:19:53 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wg0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:58223] helo=mail-wg0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/02-38250-73FFC545 for ; Fri, 07 Nov 2014 12:19:51 -0500 Received: by mail-wg0-f47.google.com with SMTP id a1so4268435wgh.20 for ; Fri, 07 Nov 2014 09:19:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=b7ucQsYyYqN93KifshJN3TgCMe+GDSXKZhB9N2ShDVk=; b=coJxgZATcmKlvZXVRPAToStcFujVilijzeQ1Ce9YtyFeQOjqqTZgix9MPfmMFmPrk3 APwL91ioZg7LZkL0zLCXh76alFTQLUq2kyfXWRUhoRfmZRXLVTVhv+5oH7Sk+cOh0DKH qq7WWsRW9yZaPs9nisrY/XTtkZHtjueSAJ2PhwpsRt2V7HczVyv6Wz4YfBdiN+hLJ+Lb aHf2XtdO1RuRDdKTYHnY3Jid50J5MW0OgVqHI17WuLHKHdOUIGVe2xNh5KAzo3n9S/qM 74DqBlskZ8+rS51ZU8bmHud3wsC2T85EheaZm6rv5Vgk2HkX8BssQiEsyb+T3/E1eZHz LEjA== X-Received: by 10.194.206.106 with SMTP id ln10mr18215301wjc.90.1415380787718; Fri, 07 Nov 2014 09:19:47 -0800 (PST) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id wa10sm7856170wjc.8.2014.11.07.09.19.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Nov 2014 09:19:46 -0800 (PST) Message-ID: <545CFF1C.90802@gmail.com> Date: Fri, 07 Nov 2014 17:19:24 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Additional splat operator usage From: rowan.collins@gmail.com (Rowan Collins) On 04/11/2014 20:55, Andrea Faulds wrote: >> If anything, I think I would expect the keys of splatted arrays to be discarded, since it seems most natural to use this in a list context, but I can imagine always having to check in the manual. > I don’t think they’d be discarded. The named parameters RFC proposes that named keys be kept by ..., and I’d prefer we do that since it makes more sense anyway: Interestingly, the current behaviour of PHP is to issue an error in this situtation ("Catchable fatal error: Cannot unpack array with string keys"), while HHVM simply strips off the keys and unpacks the values: http://3v4l.org/vi7fn However, if you present multiple arrays with integer keys, HHVM issues an error ("Fatal error: Only the last parameter in a function call is allowed to use ..."), while PHP happily merges them, appending and renumbering the keys as though array_merge() had been used: http://3v4l.org/fXE8U > [‘foo’=>’bar] and [...[’foo’=>’bar’]] should act the same, no? By that logic, [42 => true] and [...[42 => true]] should also act the same, but if we make it a short-hand for array_merge(), then numeric keys will be discarded. In fact, I think that's what concerns me about this proposal - it's *not* obvious how it should behave, and different use cases lend themselves to different answers. -- Rowan Collins [IMSoP]