Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83458 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50511 invoked from network); 22 Feb 2015 03:31:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2015 03:31:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=jgmdev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jgmdev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.180 as permitted sender) X-PHP-List-Original-Sender: jgmdev@gmail.com X-Host-Fingerprint: 209.85.217.180 mail-lb0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:37792] helo=mail-lb0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/1F-08895-C7D49E45 for ; Sat, 21 Feb 2015 22:31:09 -0500 Received: by lbvn10 with SMTP id n10so13004411lbv.4 for ; Sat, 21 Feb 2015 19:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=YociOHdyKnPsA3+xfMd2RNIyrOaOt5RTT0KtOLaMoYA=; b=zofVYh3MMGvkU0y0mZrdlZB4IF0UEIRufEy3E5u3m1R6Wo5AihFdYPd2Jv9UWVuRnp gV9MO2fB+5t5LdoFkJl6cQqQWVK3OfQKWZPEr8dpvdxu6ZQMvbj78h1gOF/p+4TAdagR GfkLO5ypTqxj9tUbTOfTVJ2zv1Bl7MrN6+qp7tZQFA38+/S4pgxhIyhBPzWiMIdMHhtk brP404wTRkVJt9HR21RRCWV2h2WgzdrDp1aH/ibqD8qpdD+WL99fj3kcBZ6x6t/iiEB8 ScOr6IlxWGv7i/CiAOTMuxNdOI0mjo/naY9EiIGb8q3tAhNuUl/a9pUaDw+oSZDRhDMG kIkg== MIME-Version: 1.0 X-Received: by 10.152.28.73 with SMTP id z9mr4309011lag.28.1424575865028; Sat, 21 Feb 2015 19:31:05 -0800 (PST) Received: by 10.112.62.228 with HTTP; Sat, 21 Feb 2015 19:31:04 -0800 (PST) In-Reply-To: References: <011801d04a07$83ab1c00$8b015400$@php.net> <015a01d04a2a$329ce7d0$97d6b770$@php.net> Date: Sat, 21 Feb 2015 23:31:04 -0400 Message-ID: Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0158c02664067c050fa4eadc Subject: Re: [PHP-DEV] Reviving scalar type hints From: jgmdev@gmail.com (JGM) --089e0158c02664067c050fa4eadc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2015-02-21 17:26 GMT-04:00 Pavel Kou=C5=99il : > Hello, > > finally got to this, after a while of thinking - the first part was > answered before, so I'll get only to the str_replace now. :) > > Basically, each of the 8 different version based on parameters does > different thing, if I'm counting it correctly. So having 8 different > declarations is IMHO valid. I know it sounds a little bit weird, but > if you really realize the amount of things the function is doing based > on the passed parameters, why would having one declaration with > multiple argument types and if statements deciding what to do based on > an argument types be better than 8 different declarations, where each > one does one predictable thing and can be documented separately? :) > > > PS: I know there's something like a declined RFC for method > overloading in the wiki (actually, just a 7 years old email), but if > there would be someone who would be interested in having method > overloading in PHP and understands PHP's internals (I don't) so he'd > be able to make the implementation, I'd like to discuss this idea with > him more and contribute somehow to a possible RFC. > > Regards > Pavel Kouril > I recently discovered this compact and lean implementation of PHP (ph7) which has overloading, scalar hinting and other nice features, so besides hhvm it could serve as an inspiration for those working on RFC's github.com/symisc/PH7 Would be nice to have function overloading on PHP now that theres going to be scalar type hinting (luckily at some point), its the best a proven approach to deal with different parameter types in a clean and straightforward way. Also some functionality at the PHP C level (when developing extensions) to register various overloads would be nice. When working on the wxWidgets wrapper for PHP I had to mix all function/method overloads into a single function which isn't too easy to do on an automated way (github.com/wxphp/wxphp/blob/master/src/media.cpp#L170). Also when working on an IDE like NetBeans it is a mess to supply an interface file for auto-completion with methods/functions that have different overloads. This kind of things may at first look like conflicting with original PHP goals, but they are pretty useful once you understand them. --089e0158c02664067c050fa4eadc--