Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71097 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15093 invoked from network); 12 Jan 2014 19:31:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2014 19:31:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:40808] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/50-13233-77DE2D25 for ; Sun, 12 Jan 2014 14:31:03 -0500 Received: by mail-wi0-f170.google.com with SMTP id hq4so2290087wib.1 for ; Sun, 12 Jan 2014 11:31:00 -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=M+DbawjtIvb905xlFKLZ753T5vWDsTo5sen0Dm3airE=; b=j/1e98taAdwXl69MuWbwpQJBlM85JWcJMEJJ+HRTK2hs22kDjsqQpvT1a1JKdD2QIM tAfRbNcVlKDhNigzRY8JBNFOUVsXTQIhYwQZtLkjumIBLECJr5PzGcqHuVrpnLrGw+Pe pXWQ1TLin6e0/XGkSiRRR6ggPRy7yDgo6KnJ2HO2G7oYEbo67EebdTIYuEumVoIO3bsY 9UfodNBKxjmau4CYIV3oFGkEWjVvIEVSMdRmeoeotcRGoomB8I4jI479xTh19GsMmeEX 2QrYHQQKuAcaifY+Tb4a+W9NI7o2HRv2j+H06Ejwb1SfV6XT3vLlcAo7MHIuoI06wlgs YWzQ== X-Received: by 10.194.170.133 with SMTP id am5mr18312828wjc.42.1389555060761; Sun, 12 Jan 2014 11:31:00 -0800 (PST) Received: from [192.168.0.2] (cpc19-brig17-2-0-cust25.3-3.cable.virginm.net. [81.101.201.26]) by mx.google.com with ESMTPSA id uq2sm9588101wjc.5.2014.01.12.11.30.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 11:31:00 -0800 (PST) Message-ID: <52D2ED5F.4000706@gmail.com> Date: Sun, 12 Jan 2014 19:30:39 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <581A185E-0F00-4B49-AA87-859D75E63BA2@googlemail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Revisiting the "Named Arguments" RFC From: rowan.collins@gmail.com (Rowan Collins) On 12/01/2014 08:16, Patrick Schaaf wrote: > Regarding Syntax at the call site, I feel that it is exactly right the way > it is proposed / implemented now. That way mirrors most closely the syntax > of static array definition, while saving some typing (omitting of double > quotes) where key names do not clash with keywords. In fact, once > established, I would love static array initialization to also permit > nonclashing keys to omit the doublequotes :) Personally, I'm against allowing barewords to act as strings wherever they don't - currently - clash with keywords, for two reasons: Firstly, the concept in general is prone to errors in the programmer's memory and the evolution of the language regarding which words are and aren't allowed. One of the few differences between JSON and an actual Javascript object declaration is that keys in JSON are *always* quoted, and I think that was a good move on Crockford's part. People get in the habit of using unquoted object keys in JS, and then have to dig through the code to figure out which name some parser is choking on. Secondly, barewords already have a specific meaning in PHP: constants. By convention, constants are UPPER_CASE, but the engine doesn't actually care, and array(foo => bar) is actually valid PHP, but might be equivalent to array('six by nine' => 42), if that's what 'foo' and 'bar' are define()d as. I'm glad the introduction of shortened array syntax didn't change this meaning, and am not convinced named parameters should either, unless the syntax is chosen to *always* use barewords, with no variable interpolation or ambiguity. As an aside, what I *would* like to see is the end of the "if a constant isn't declared, assume it's actually a string" fallback, which feels like a hangover from PHP's pre-history. The fact that an undeclared class constant is a fatal error, but an undeclared global constant is a notice is one of those inconsistencies for which PHP is notorious. Regards, -- Rowan Collins [IMSoP]