Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35658 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24463 invoked by uid 1010); 20 Feb 2008 20:25:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24447 invoked from network); 20 Feb 2008 20:25:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2008 20:25:38 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; 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:20488] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/A3-30965-0CC8CB74 for ; Wed, 20 Feb 2008 15:25:37 -0500 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 20 Feb 2008 22:25:41 +0200 Received: from [192.168.16.90] ([192.168.16.90]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 20 Feb 2008 12:25:37 -0800 Message-ID: <47BC8CB9.9050602@zend.com> Date: Wed, 20 Feb 2008 12:25:29 -0800 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Marcus Boerger CC: php@stefan-marr.de, internals@lists.php.net References: <001c01c87264$3c01b4e0$b4051ea0$@de> <1203461114.24580.45.camel@localhost> <47BB5EFE.4080704@zend.com> <194023457.20080220210940@marcus-boerger.de> In-Reply-To: <194023457.20080220210940@marcus-boerger.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Feb 2008 20:25:37.0755 (UTC) FILETIME=[C1092AB0:01C873FE] Subject: Re: [PHP-DEV] RFC: Traits for PHP From: stas@zend.com (Stanislav Malyshev) Hi! > if we go the route of allowing that, then we have to do some protocl > checks. Meaning if a renamed/aliased method will become an implementation of > an abstract method then of course it has to be compatible. The beigger I'm kind of confused on a use case for that. Suppose you have trait TFoo that does some API - like implementing serialization, for example. And then you have some abstract method bar() that is supposed to do something unrelated - like convert pounds to kilograms. And then you just rename one of the methods of TFoo into bar() and suddenly it starts being used for converting pounds to kilograms just because it has the same argument count? I don't see any sane application structure working this way. What would be the use case of taking methods from one API and using them as implementation for totally unrelated parts of other API? What if one of the APIs changes? What if change required to implement TFoo but bar() should stay the same? This just looks like very cludgy attempt to avoid typing a few extra lines, which will definitely will come back to bite the developer in the future. I think this is important - to figure out what is the good use case for this. > dropped or renamed then there is a problem, called missing function. We > could avoid that easily if we have a compiler that allowed us to check > which functions are being called. Becasue then we could easily prevent a We can't - as I already mentioned, call resolution is dynamic in PHP, which means compiler can't check which methods are called. On top of that, nobody said methods are always to be called on $this with -> operator - there are many other ways to call a method on an object. > In PHP we always allowed all kinds of nasty. We even hesitate to increase No, we didn't allow all kinds of nasty. PHP never had dynamic method addition, dynamic object/class redefinition, etc. even though engine-wise it's completely possible. That's the domain of hackish extensions like runkit and IMO it should stay there - in it's own closet which is clearly labeled "beware of the leopard". I would have no objection for runkit to have traits-like functions - in fact, I think it can do it right now. Having this in core is another, very different business. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com