Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29939 invoked from network); 6 Sep 2013 17:25:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Sep 2013 17:25:57 -0000 Authentication-Results: pb1.pair.com header.from=adam@adamharvey.name; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=adam@adamharvey.name; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adamharvey.name designates 209.85.223.182 as permitted sender) X-PHP-List-Original-Sender: adam@adamharvey.name X-Host-Fingerprint: 209.85.223.182 mail-ie0-f182.google.com Received: from [209.85.223.182] ([209.85.223.182:45592] helo=mail-ie0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/94-05619-4201A225 for ; Fri, 06 Sep 2013 13:25:57 -0400 Received: by mail-ie0-f182.google.com with SMTP id aq17so7422241iec.41 for ; Fri, 06 Sep 2013 10:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamharvey.name; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=xQcdYtNjWfoTfsCb0j5FkooUfpetx0Jv5Z7m6ZmzlZI=; b=cChbuPDMhYgI46+Gx1OmzGRJB3HlDDGlTiDHpv5/oznJmeDgNs6t6YGaG2096xh0dW Yf43TKsYzTmCAgguDIZbbCh6Wzm1HdvK9hqxVXQZgrCScPwvheySx1zu3aXXLUQ1DNxQ wB7teCdXDoSj/Bvc7JQ69Y50D4DTmpkEbIQJA= 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:cc:content-type :content-transfer-encoding; bh=xQcdYtNjWfoTfsCb0j5FkooUfpetx0Jv5Z7m6ZmzlZI=; b=HNORb3I870vw1r1/8xeCxYGegEig4KfUIxG/Tb3tmnWJbsJX8xcu1wLQ28uPAviPng Ir/S3cqPz+UAP5XqW+dTv60/NguWB39h+cxtv81KoJsrwV6IwcNdCQg34b2K9snH87iz 16vHHAw+ZkS5D2N7sPgb10du+WkD0I+jiuam+RbdlmHdPFUeuyULU0vWmcB6GA000sC8 WwRxHadBFjzCDQ13uWICZCLZkzrFLBK/sjmhrqKBOsq/C2oJxcvBW/ogmaQSkLn9S54U wahgRjMGWVbSlHRVTso41c0e1e3OP01x9fkIFrgj19VTzjf8wwNVGFAsjfDKusqfdKEh cJiA== X-Gm-Message-State: ALoCoQmtNQ3SO9RjWD4Uuyof4XA+1ewC4A8E8sKxzEMM1OT3G2ypb46fw3ldmLj31ZZsCblZP9/b X-Received: by 10.50.124.65 with SMTP id mg1mr10844052igb.43.1378488354496; Fri, 06 Sep 2013 10:25:54 -0700 (PDT) MIME-Version: 1.0 Sender: adam@adamharvey.name Received: by 10.42.206.208 with HTTP; Fri, 6 Sep 2013 10:25:34 -0700 (PDT) In-Reply-To: References: Date: Fri, 6 Sep 2013 10:25:34 -0700 X-Google-Sender-Auth: X_HYqBmQXrxhyyf7r9dMG15GEp0 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Named parameters From: aharvey@php.net (Adam Harvey) On 6 September 2013 09:39, Nikita Popov wrote: > The RFC and implementation are not yet complete. I mainly want to have > feedback on the idea in general and on the Open Questions ( > https://wiki.php.net/rfc/named_params#open_questions) in particular. Thanks for proposing this. I haven't looked at the patch yet, but I'm all for the feature. My thoughts on your open questions: Syntax: I suspect this will end up having to go to a vote (classic bikeshed), but I'm on the func('foo' =3D> 'bar') train. :foo doesn't make sense in a PHP context (we'd have to implement that across the language, not just for function calls), : as a key-value separator would only work if it was also supported in array literals, and =3D feels a little wrong for this. I don't really like the unquoted parameter names so much; it's inconsistent with array literals and bare words as strings is something that's been discouraged for a long time. Variadics/splat: collecting both named and positional arguments into one array seems reasonable to me. I think the main use case there would be option parameters, which you'd have to validate anyway, so positional parameters would be dealt with at that point =E2=80=94 I don't s= ee separate arrays as conferring any great advantage in terms of validating parameters, and it's no simpler conceptually. call_user_func_array: for consistency, we might want to consider adding an analogue function that deals with named parameters, even though it would work via $callable(...$kwargs). Contracts: I agree with you, basically =E2=80=94 it would have to be an E_STRICT or thereabouts, with the possibility of revisiting come a hypothetical PHP 6. Adam