Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100178 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65066 invoked from network); 11 Aug 2017 07:51:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2017 07:51:41 -0000 X-Host-Fingerprint: 62.31.75.76 76.75-31-62.static.virginmediabusiness.co.uk Received: from [62.31.75.76] ([62.31.75.76:14955] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/E3-34801-C026D895 for ; Fri, 11 Aug 2017 03:51:40 -0400 Message-ID: To: internals@lists.php.net References: In-Reply-To: Date: Fri, 11 Aug 2017 08:51:33 +0100 Lines: 1 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3564.1216 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3564.1216 X-Posted-By: 62.31.75.76 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax From: TonyMarston@hotmail.com ("Tony Marston") "Andreas Hennings" wrote in message news:CAH0Uv3HQK5wjcd_-9GynMw34H78ZTv09q9bc=yZ10JBbeT=VOA@mail.gmail.com... > >On Fri, Aug 11, 2017 at 12:01 AM, Devnuhl Unnamed >wrote: >> Would isset($suffix) not suffice here? > >You mean like so? > >list($prefix, $suffix) = explode(':', 'string_without_suffix'); >if (!isset($suffix)) { > .. >} > >The isset() is too late here, because the list() will already cause an >error. > > >> Other concerns fall around list() already being a difficult thing for >> people to understand I agree. >I fail to understand what is difficult about it. The point is that other people have difficulty understanding what is supposed to be a simple feature which is now being expanded to include more options which change its behaviour. >And "destructuring" is a common concept in programming languages. >https://www.startpage.com/do/search >?query=destructuring&cat=web&pl=chrome&language=english >https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment > >The following already works in Javascript: >[a, b, c, d = 'else'] = ['aa', 'bb', 'cc']; >I just tried it in my Chromium console. That fact that something like this exists in another language is no reason to add it to PHP. -- Tony Marston