Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32763 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47669 invoked by uid 1010); 14 Oct 2007 19:50:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47654 invoked from network); 14 Oct 2007 19:50:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Oct 2007 19:50:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:47745] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/C8-02105-02372174 for ; Sun, 14 Oct 2007 15:50:57 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 14 Oct 2007 21:50:53 +0200 Received: from [192.168.17.80] ([192.168.17.80]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Sun, 14 Oct 2007 12:50:49 -0700 Message-ID: <4712731B.5070501@zend.com> Date: Sun, 14 Oct 2007 12:50:51 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Hans Moog CC: Alexey Zakhlestin , internals@lists.php.net References: <7C37FF3A0196094F95430BA95952032211B7C5@s1.mkj.lan> <7C37FF3A0196094F95430BA95952032211B7C7@s1.mkj.lan> <7C37FF3A0196094F95430BA95952032211B7C8@s1.mkj.lan> <7C37FF3A0196094F95430BA95952032211B7CB@s1.mkj.lan> In-Reply-To: <7C37FF3A0196094F95430BA95952032211B7CB@s1.mkj.lan> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 14 Oct 2007 19:50:49.0921 (UTC) FILETIME=[854D3B10:01C80E9B] Subject: Re: AW: [PHP-DEV] Method overloading by method signature From: stas@zend.com (Stanislav Malyshev) > But if you want to be more strict and limit the coder to use your > functions only with a specific parameter signature (and thats the The purpose of signature overloading in most languages isn't input type control, it's different functionality on different types. However, unlike many other languages, PHP does not have static typing, and that would not allow to know which function is called immediately, only at runtime. This has both performance impact and code transparency impact - you wouldn't know which function will be called until runtime. I am not convinced this added complexity serves any real need - though you are welcome to prove otherwise, i.e. present some use case when one can't do without signature overloading. > only reason to use type hints - to ensure the method is used > correctly and build more robust applications), it is better to tell BTW, I'm not sure how exactly it makes the code more robust - if you call it with wrong type and it's not checked, the app would probably die on fatal error. If you call it with wrong type and it is checked, the app would die on fatal error couple of lines above. Unless you use some kind of static analysis tool to verify your app prior to deployment (if you know such tools please tell me!) I don't see much difference here, mostly syntax sugar and enforcing right style (which is not bad - just it's not that big a deal). > lost in this move (boo!). No longer can you override a method & > provide an incompatible signature. This mixture of strict OO + PHP's > traditional loose typing is really shooting PHP in the foot. If you don't want strict signatures - why you are using them? Nobody forces you to type your arguments. And inheritance is certainly not for overriding objects with incompatible signatures, if you try to do it you are misusing it. > I think, that this ist the reason why nearly nobody uses this great > new feature (to ensure that the passed parameters are correct), The above statement is not true. This feature is used by many developers. Please stop using "unless you do it my way, nobody will use PHP" argument - it doesn't work. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com