Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100208 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79792 invoked from network); 14 Aug 2017 09:35:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2017 09:35:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=bjorn.x.larsson@telia.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=bjorn.x.larsson@telia.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain telia.com from 81.236.60.154 cause and error) X-PHP-List-Original-Sender: bjorn.x.larsson@telia.com X-Host-Fingerprint: 81.236.60.154 v-smtpout1.han.skanova.net Received: from [81.236.60.154] ([81.236.60.154:56338] helo=v-smtpout1.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/D4-34801-6CE61995 for ; Mon, 14 Aug 2017 05:35:03 -0400 Received: from [192.168.7.8] ([195.198.188.252]) by cmsmtp with SMTP id hBlzdinGYPPY2hBlzd2SeO; Mon, 14 Aug 2017 11:35:00 +0200 To: Andreas Hennings , Andreas Treichel Cc: PHP internals References: Message-ID: Date: Mon, 14 Aug 2017 11:35:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: sv X-CMAE-Envelope: MS4wfAaRjPLEDSdCOAWbUEw8NhKMVAumYHp9uo7yBTXeX++Q+Vd2PAE2MGLj/Xuuq9fVY9sRPOj/u1rxiYn43psa9NgtLd+N2uka0k7dPXolIAWH0O/GXFgU 5A/yAYdbephTO+OyxWCUjbh5BDkLksVVU+Vfa0Tt4iTb8OuDZmNr92KxBMZJ5PEDDtiRirGn5lZjxJ/sli3UBu/VXIm8Kr2+p7JzbEwJD6UhWXy3MSu/qnDl os1WLUBrVlPf781yD4kpKA== Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2017-08-12 kl. 02:37, skrev Andreas Hennings: > This is true, I remember having done it in the past. > > I still think it would be nice and feel natural to have the default > values directly built into the list construct. > > It would be a bit faster, because it does not have to allocate a new > temporary array. > > Whether this difference matters depends on the case. > In my own philosophy, every code that I write to be reusable, could at > some point be used in a situation where it is repeated a lot, and thus > has a performance impact. So for my taste, it does matter. > > This said, I understand it not having the greatest priority. > > > > On Fri, Aug 11, 2017 at 7:46 PM, Andreas Treichel wrote: >> You can merge the result with default values like this: >> >> [$foo, $bar, $foobar] = explode(':', 'foo:bar') + [23, 42, 1337]; >> var_dump($foo, $bar, $foobar); >> >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> One could argue that: [$foo, $bar, $foobar = 1337] = explode(':', 'foo:bar'); is more readable. I find it a small but nice addition that doesn't clutter the language. r//Björn