Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89138 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 733 invoked from network); 10 Nov 2015 03:15:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2015 03:15:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.178 as permitted sender) X-PHP-List-Original-Sender: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.214.178 mail-ob0-f178.google.com Received: from [209.85.214.178] ([209.85.214.178:35344] helo=mail-ob0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/DB-13667-64161465 for ; Mon, 09 Nov 2015 22:15:19 -0500 Received: by obbnk6 with SMTP id nk6so23235720obb.2 for ; Mon, 09 Nov 2015 19:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=JRdouo+NmYM+kkCMCFaEUevpkUHUipJbyhPxkRe4cYI=; b=eE9PCzeY1kURp7bSG3bmB1v9F+KFDNukdA5guVbwLkDgKaKZimz9eotzg2wwrEAXEm iqJdsxm67OL2HaFBLl5RTifyXp9biZVNSNFARVYY46OGoHFEXT/WyRMyOqmH8Po1r8Qx 99rf6rY0RoUGzGR7j4yBkHpoeSIdiL0uHdNJb85atlqOWZ8FX6tWstyjGN+1uYw66Xnj rD4gum70AOk238VXSKECnSxcHD8/2MbWw78Y8omv6PUPTG1wUdm+GFDmnQQsR0ZCzeRJ 3XRnplygM2B2O9ZXuoJe904y0augCaYZNqoHprAiUMty3i+o3sT1Z1YNJaubbxGMSdD2 lY+w== X-Received: by 10.60.226.194 with SMTP id ru2mr646441oec.12.1447125315484; Mon, 09 Nov 2015 19:15:15 -0800 (PST) MIME-Version: 1.0 Sender: reeze.xia@gmail.com Received: by 10.202.105.132 with HTTP; Mon, 9 Nov 2015 19:14:56 -0800 (PST) In-Reply-To: References: Date: Tue, 10 Nov 2015 11:14:56 +0800 X-Google-Sender-Auth: J97Nwnu_H89P0P_dywRbF1k4oss Message-ID: To: Dan Ackroyd Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11369cb66000970524271e42 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax From: reeze@php.net (reeze) --001a11369cb66000970524271e42 Content-Type: text/plain; charset=UTF-8 Hey Dan, On 9 November 2015 at 23:24, Dan Ackroyd wrote: > Hi Reeze, > > On 9 November 2015 at 13:35, reeze wrote: > > Hi internals! > > > > I'd like to open a discussion on the RFC to allow set default values for > > list() assignment: https://wiki.php.net/rfc/list_default_value. > > > > What is your idea? > > I find the list construct to be quite magic already. Isn't it possible to get the affect that you want without adding anything to the core by > doing this: > > $defaults = ['default', 'default']; > $input = [1]; > > list($a, $b) = array_replace($defaults, $input); > > I'd find that way easier to understand and explain to junior devs, > I saw the contrast way, it is more complex ;-). This seems like a trick. Many feature could also be remove, such as I refered in RFC: Null coalesce "??" and Ternary Operator "?:" And the trick is trick. If you want to unpack nested array. list($a, list(list($b))) = $array Then you might need a new trick to do that. You know we have default for function declaration: function func($a='default') {}; and almost all language have the feature, it is easier to understand from my perspective. > compared to having more functionality added to the 'list' magicness. > > cheers > Dan > -- Reeze Xia http://reeze.cn --001a11369cb66000970524271e42--