Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70019 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73239 invoked from network); 5 Nov 2013 20:21:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Nov 2013 20:21:50 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:52613] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/C6-40963-D5359725 for ; Tue, 05 Nov 2013 15:21:49 -0500 Received: from [192.168.2.20] (ppp-188-174-63-171.dynamic.mnet-online.de [188.174.63.171]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 65FD8404F5; Tue, 5 Nov 2013 21:22:03 +0100 (CET) To: Kevin Ingwersen Cc: Nikita Popov , Oleg Poludnenko , PHP internals In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Tue, 05 Nov 2013 21:21:27 +0100 Message-ID: <1383682887.4097.47.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP RFC: Deffering functions by arguments (count or/and type) From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Tue, 2013-11-05 at 19:22 +0100, Kevin Ingwersen wrote: > I had nothing to do, With such statements be careful: A mail here goes to a thousand or so readers, saving them time is notable and helps to get responses. > so here we go: https://gist.github.com/IngwiePhoenix/e7fbee9f769fc137250d There are two things which have to be solved for this being possible: * There needs to be a backwards compatible way to handle the fact that PHP functions accept variable amounts of parameters currently * This has to be implemented in a way not slowing down all function calls For the first item think about code like this: class B { function foo() { func_get_ars(); } } class E extends B { function foo($bar = null) { func_get_ars(); } } $o = new E; $o->foo(1, 2); With the logic from the idea B::foo() and E::foo() are different methods, with current PHP they are overriding each other. Currently this call E::foo(). what should happen After your change? Break lots of code? For the second item: Function calls in PHP are relatively slow already and we have no good way to "bind" the calls during compilation so we always have to resolve the call at run time. Consider this: function foo(someInterface $o) { $o->method(); } There we don't know which method to call. Unless there is a good idea and a patch I expect this to slow down each and every function call. which in my perspective is a no-go. Languages like C++ "mangle" the parameters in the function name, which is complicated ina dynamic language lie PHP, and have more information (when compiling that sample function above PHP doesn't need the definition of someInterface, yet, it might not exist, yet) Maybe somebody has an idea for a good implementation. But till then I'd put this aside. johannes