Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68959 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73352 invoked from network); 7 Sep 2013 23:28:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2013 23:28:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:50682] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/E1-00660-186BB225 for ; Sat, 07 Sep 2013 19:28:04 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 1DD1370276E8; Sun, 8 Sep 2013 00:27:59 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id 47yVqv7ubIqJ; Sun, 8 Sep 2013 00:27:58 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 5B81970276E5; Sun, 8 Sep 2013 00:27:58 +0100 (WEST) Received: from [IPv6:2001:981:8103:fc:96de:80ff:fe7e:525f] (unknown [IPv6:2001:981:8103:fc:96de:80ff:fe7e:525f]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 25B942004F88; Sun, 8 Sep 2013 00:27:58 +0100 (WEST) Message-ID: <522BB60F.8030903@nebm.ist.utl.pt> Date: Sun, 08 Sep 2013 01:26:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20100101 Thunderbird/22.0 MIME-Version: 1.0 To: Nikita Popov CC: PHP internals References: <522A47BC.30100@nebm.ist.utl.pt> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Named parameters From: glopes@nebm.ist.utl.pt (Gustavo Lopes) On 06-09-2013 23:54, Nikita Popov wrote: > On Fri, Sep 6, 2013 at 11:23 PM, Gustavo Lopes wrote: >> >> I think the correct course of action is just to drop support for extra >> named arguments. Just add an extra array argument to the function and you >> have equivalent functionality without having to go through these edge cases. >> > > Dunno, personally I don't have a strong need for the extra named args. > That's something Stas considered important (in the discussing re skipparams > RFC). Would be interesting to know for what they are currently used in > Python/etc and whether those use cases are sufficiently important to us. > The advantages would have to be very significant in order to justify breaking all the call forwarding code out there relying on call_user_func() and func_get_args(). It also unnecessary complicates the variadics calls for the callee that now receives a potentially non-numeric array. The caller may have slightly better syntax, but there being no information on support of extra named parameters on the signature is an extra complication. And at this point I haven't seen any convincing argument as to how this is more than marginally better than an extra array argument for the caller and any better at all for the callee. > >> I also disagree about your idea about how to handle changed parameter >> names. Having an E_ERROR here is absolutely unacceptable. This would be a >> major BC break (not to mention inconsistent with the other other signature >> mismatches are handled). > > > Yes, I certainly do not want to throw any fatal-ish error here. Maybe I > didn't make that clear in the RFC. (What do you mean with "inconsistent > with the other other signature mismatches are handled" though? For > signature mismatches involving interfaces we currently use fatal error. > Signature mismatches between classes are E_STRICT.) > I meant the E_STRICT on rather more worrying situations like: class A { function a(array $a) {} } class B extends A { function a(SplArray $a) {} } >> In fact, I think ANY message here would waste millions of $currency in man >> hours. I can't think of any easy solution there. An alternative solution >> would be to keep a flag on whether argument names changed and refuse to >> accept named arguments in the case a call is made to an instance whose >> class or some its parents changed parameter names, but this comes with some >> memory penalty. >> > > Eh, I don't know. Getting an error at the call-site is already too late. > You'll get one anyway because the parameter name doesn't exist. Unless > mismatching parameter names are exceedingly common, I'd think a lowly > E_STRICT level error would be bearable. > Too late for what? If there is a mismatch but named arguments are not used, there is no problem with the code (if you don't consider named parameters not being permitted a problem). In any case, a more specific error is better than a generic one. That said, I'm on the fence here because it's not really nice to have named parameters being permitted in a call to method A::b() but having the same call forbidden to B::b(), where B extends A. Regards -- Gustavo Lopes