Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90815 Return-Path: <3n7r0py@gmail.com> Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37223 invoked from network); 21 Jan 2016 23:00:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2016 23:00:05 -0000 Received: from [127.0.0.1] ([127.0.0.1:17041]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id F9/C4-09073-4F261A65 for ; Thu, 21 Jan 2016 18:00:04 -0500 Authentication-Results: pb1.pair.com header.from=3n7r0py@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=3n7r0py@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.43 as permitted sender) X-PHP-List-Original-Sender: 3n7r0py@gmail.com X-Host-Fingerprint: 209.85.213.43 mail-vk0-f43.google.com Received: from [209.85.213.43] ([209.85.213.43:34835] helo=mail-vk0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/50-09073-20C21A65 for ; Thu, 21 Jan 2016 14:05:39 -0500 Received: by mail-vk0-f43.google.com with SMTP id k1so28806928vkb.2 for ; Thu, 21 Jan 2016 11:05:38 -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:content-type; bh=hI4LNyfufTXdcq2aTyAU7fnf0iV1Z1NL18uSWBefkzU=; b=pG3A6wO0femCrme1iTQJHQFFtw2ckOfzAR7SF4WI3ASaaIZ7DRsUFFIY8AyUT0JL4A hXJurTh4EFewYiVPWypUk9Ma6x7BaVuydnW4hdnBbW2DU2/Fa3lxx4ix7Pc49Szg13cK XPuj1dOKTT5BIqRKnSmq+aOOw70y9Dx+Eh1vPsYuZDSFkvjFX0eEZ9Y2ypHzTqq+477f +P1o+UAHKiIH5D/qA/3fpXepS60beBe3qmW3HU/YUzWC5neziDXldWwgo3+VNvX70V4N TvYErhNMtOfmVGe9KwBCXrTyLK6hSjqVtoFQGfK+ISHDcGSwJkxyAamvdIdhXxeQaEQV WyYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:content-type; bh=hI4LNyfufTXdcq2aTyAU7fnf0iV1Z1NL18uSWBefkzU=; b=e5Xkqqy61D8/IMcc6ov7IrD7Nt/AOxSov0XIZcHM0wprVWGsWX/ZcEuhFZoI3I+azc MJ9i7nDBm71m8wroZQy5mrC0IZVGOaXuXDmnYp0Ah3vA+YfytMP/VHJga0BcWR/0jh4P Dd1zq3ZWf+tQKJgUAN0wz2o/RYbSWdzYwPF3XpJ0vZp9RO2XByZQqp5Rffgx2D3pLwGr vwonNTt6hUZnbZeuJ07UZ/EqFsjb1Pvq0rd9W5luGV/yjLJXW/uE7UoEMNiUVziBHtO7 zuwNu20hOJDtEZyIJQq8Z4VOMuWbFDhOOO2Ry71sjc/Oc7HayF8FtXrzw+BzS8ZYP2HE 8sBA== X-Gm-Message-State: ALoCoQnn4C1vOdd0pClNauWP6lMo9gfdz2qvI6eIcHkbXMoAsdwSejAXYvxhU2ymr89kf2CnLudJr7owMYjeoY3ZDiqJ8JWDgw== X-Received: by 10.31.149.78 with SMTP id x75mr29931976vkd.103.1453403135734; Thu, 21 Jan 2016 11:05:35 -0800 (PST) MIME-Version: 1.0 Sender: 3n7r0py@gmail.com Received: by 10.31.141.71 with HTTP; Thu, 21 Jan 2016 11:04:56 -0800 (PST) In-Reply-To: References: Date: Thu, 21 Jan 2016 13:04:56 -0600 X-Google-Sender-Auth: vWUQwZumpZ9ufLW4TobddhK7b2g Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a114267489efa510529dcc92c Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax From: devnuhl@gmail.com (randomly there) --001a114267489efa510529dcc92c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 1/21/2016 8:49 AM, reeze wrote: > Bump this to continue discussion of this RFC ( > https://wiki.php.net/rfc/list_default_value). > > In case some of you didn't follow it before. This RFC propose to allow se= t > default value in list() assignment=EF=BC=9A > > list($a =3D 'default value') =3D $arr; > tl;dr - List is like a contract that the array must honor. This would seem to me a bad idea as it is already difficult enough getting people to not think of list() as a function, but as a construct that imports to named variables elements from an array. You should also likely only be using list for arrays with known structures, otherwise how do you know you're defaulting the right variable? Do you default in front, or in back? Which values are missing from the array that should be imported to variables and why? Should you not be populating the array with default values? For this to even be discussed, I feel like there would need to be a few concrete examples of how this would be useful. If you're passing an array to the list construct, you're telling PHP that you know how many values are in it, and that you want them all to be filled with a value. For example, in a dynamically generated array, the value that is missing may be in the middle, but you can't determine where the missing value is, only that the array is not the appropriate length. If it's the result of a database query, the query should be returning all values that will be populated into variables, anything missing is itself incorrect, and building the list construct in a way to handle the data being incorrect seems counterproductive. Instead the query should return all the data that is expected by the construct. List is like a contract that the array must honor. Also, what happens when you feed a defaulted list construct bad input that would currently result in the values being set to NULL? Would they still be set to NULL, or would they be populated with the default value provided? Adjusting the example from the documentation: // list() doesn't work with strings list($bar =3D 'default') =3D "abcde"; var_dump($bar); // NULL or var_dump($bar); // string(7) "default" Sorry if this got a little long. Definitely think there needs to be some justification behind it, though, and concrete examples of usefulness as mentioned earlier. And generally speaking, I think treating constructs as functions in terms of definition should be avoided. Thanks. Chris --001a114267489efa510529dcc92c--