Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70280 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15958 invoked from network); 22 Nov 2013 09:55:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 09:55:13 -0000 Authentication-Results: pb1.pair.com header.from=ua.oleg@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ua.oleg@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.50 as permitted sender) X-PHP-List-Original-Sender: ua.oleg@gmail.com X-Host-Fingerprint: 209.85.216.50 mail-qa0-f50.google.com Received: from [209.85.216.50] ([209.85.216.50:44455] helo=mail-qa0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/53-28674-FF92F825 for ; Fri, 22 Nov 2013 04:55:12 -0500 Received: by mail-qa0-f50.google.com with SMTP id i13so3973698qae.9 for ; Fri, 22 Nov 2013 01:55:09 -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:cc:content-type; bh=PReaupmG7SWLDQMn4VtdIH19GcQtzYSg149edno5iZ8=; b=zlxJKcGtQ0yVtJfDYYEoKa8tZt1VxdumgKNoKTjAIjRUuhwTbcZk+q0++j3mf2VchZ McvBvJfxWzOP4BZEFuKgdc/QzqVj7yLuFrlVV9jvP+Iduw6ZBjW11Mj9ns9NVvuGmUg7 rAC7RYuFQ8Q9yz4I6HexJ845KIW/G5VE8DxhFs2aaHxf2qM7qoUKAVXTKRzZOBCyInYa +jRrKpIiG1b4lp3ixJLlTqaAiYTq74nsIXeT7cE5imMK9alFft2HA4BiChNn4mPLAG5S +ACbRPoHq6zJBm44o/jAyYJNPL7Zlf1uNqWgzhEt8qHvWRh/xCzz2BjL3+VYdNnP2ly/ 65Ig== X-Received: by 10.224.72.15 with SMTP id k15mr19912096qaj.58.1385114107967; Fri, 22 Nov 2013 01:55:07 -0800 (PST) MIME-Version: 1.0 Sender: ua.oleg@gmail.com Received: by 10.224.21.71 with HTTP; Fri, 22 Nov 2013 01:54:46 -0800 (PST) In-Reply-To: <1383682887.4097.47.camel@guybrush> References: <1383682887.4097.47.camel@guybrush> Date: Fri, 22 Nov 2013 11:54:46 +0200 X-Google-Sender-Auth: u5zLU3PyHRips-Zn2rgvgsVOvmU Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Kevin Ingwersen , Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=047d7bf1609c61182c04ebc10226 Subject: Re: [PHP-DEV] PHP RFC: Deffering functions by arguments (count or/and type) From: oleg@poludnenko.info (Oleg Poludnenko) --047d7bf1609c61182c04ebc10226 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Johannes, thank you for your complete response. I've made a complex brainstorm with my colleagues and with a local community ( http://habrahabr.ru/post/198980/). So it took a long time. Nevertheless I've gotten an answers to your questions. And here they are. We need to implement two new modifiers: *override* and *dynamic*. The first one should be used to designate a function which overrides it's parent: *override public function* calcPerimeter() { ... } We are allowed to override only methods defined as *abstract* (without implementation) or *dynamic* (contai= ns implementation). So the new modifier *dynamic* designates that function could be overridden and it has implementation. Here there is a code sample: https://gist.github.com/uaoleg/7596995 On Tue, Nov 5, 2013 at 10:21 PM, Johannes Schl=C3=BCter wrote: > 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 =3D null) { func_get_ars(); } > } > $o =3D 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 > > > > --047d7bf1609c61182c04ebc10226--