Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36866 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82923 invoked from network); 8 Apr 2008 10:13:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2008 10:13:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=krister.karlstrom@arcada.fi; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krister.karlstrom@arcada.fi; sender-id=pass Received-SPF: pass (pb1.pair.com: domain arcada.fi designates 193.167.33.246 as permitted sender) X-PHP-List-Original-Sender: krister.karlstrom@arcada.fi X-Host-Fingerprint: 193.167.33.246 hipper.arcada.fi Received: from [193.167.33.246] ([193.167.33.246:51180] helo=hipper.arcada.fi) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/BA-22202-3354BF74 for ; Tue, 08 Apr 2008 06:13:08 -0400 Received: from [127.0.0.1] (juuri.arcada.fi [193.167.33.38]) by hipper.arcada.fi (8.13.8/8.13.8) with ESMTP id m38AD4ba032347; Tue, 8 Apr 2008 13:13:04 +0300 Message-ID: <47FB4531.4030605@arcada.fi> Date: Tue, 08 Apr 2008 13:13:05 +0300 Reply-To: karlstrk@arcada.fi Organization: Arcada Polytechnic User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Arvids Godjuks CC: internals Mailing List References: <1207539695.5736.42.camel@pena> <8d7b8c130804062157j60871630r6c3b27c4d3245cb9@mail.gmail.com> <1207576676.5331.49.camel@felipe> <47FA507D.2070108@cschneid.com> <10845a340804071346m251eae49j907b4a6ca7c607be@mail.gmail.com> <47FA94B2.6050704@cschneid.com> <9b3df6a50804080202n456fc08blfef3e70034d95c1c@mail.gmail.com> <47FB3830.2080907@arcada.fi> <9b3df6a50804080305i3bff79b4n7237ebb0be70db4@mail.gmail.com> In-Reply-To: <9b3df6a50804080305i3bff79b4n7237ebb0be70db4@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV version 0.91.2, clamav-milter version 0.91.2 on hipper.arcada.fi X-Virus-Status: Clean Subject: Re: [PHP-DEV] Return type hints From: krister.karlstrom@arcada.fi (=?UTF-8?B?S3Jpc3RlciBLYXJsc3Ryw7Zt?=) Yes indeed you can implement it using the __call method, but it would be more readable if the language structure itself would support it. I suggested this just because I think that this is the most common way of using overloading, thus this probably would make sense to lot of users out there. But it was only a suggestion among others. /Krister Karlström Arvids Godjuks wrote: > Em, you have __call method in classes - via it you could implement ANY logic > for overloading. It's written in manual here: > http://www.php.net/manual/en/language.oop5.overloading.php > > KISS should be followed - no C++ style overloading is needed, PHP is a > script language without strict type hinting. > > 2008/4/8, Krister Karlström : >> Hi! >> >> This is maybe getting a bit out of topic now, but what about >> function/method overloading using type hinting: >> >> function myfunc(string $data) { } >> function myfunc(int $data) { } >> function myfunc(myClass $data) { } >> >> This currently causes an error in PHP 5.2.5 that function myfunc() can't >> be redeclared. This would in my opinion be very useful for methods in >> classes. >> >> Greetings, >> Krister Karlström, Helsinki, Finland >> >> Arvids Godjuks wrote: >> >> I think type hint's would be good optional functionality. Those who need >>> will use it, others will not. I'd probably use it in some cases. >>> Especially >>> if named parameters are implemented. >>> >>> Sometimes what I really want is named parameter pass like >>> >>> function myfunc(array $array, string $string = null, int $someint = 0){ >>> } >>> >>> myfunc($myArray, someint = $mySomeInt);