Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29367 invoked by uid 1010); 21 Feb 2008 08:42:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29335 invoked from network); 21 Feb 2008 08:42:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2008 08:42:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=mls@pooteeweet.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mls@pooteeweet.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pooteeweet.org from 85.10.196.195 cause and error) X-PHP-List-Original-Sender: mls@pooteeweet.org X-Host-Fingerprint: 85.10.196.195 serveforce1.backendmedia.com Linux 2.6 Received: from [85.10.196.195] ([85.10.196.195:60556] helo=serveforce1.backendmedia.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/C4-20678-A593DB74 for ; Thu, 21 Feb 2008 03:42:03 -0500 Received: from [192.168.84.34] (office-zh.liip.ch [91.192.102.250]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by serveforce1.backendmedia.com (Postfix) with ESMTP id E197C122461D; Thu, 21 Feb 2008 09:42:25 +0100 (CET) Cc: , , =?ISO-8859-1?Q?Marcus_B=F6rger?= , =?ISO-8859-1?Q?Johannes_Schl=FCter?= , "Sebastian Bergmann" , "Alexandre Bergel" , "Falko Menge" , "Sara Golemon" , Message-ID: To: Andi Gutmans In-Reply-To: <698DE66518E7CA45812BD18E807866CE014A8D9D@us-ex1.zend.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Thu, 21 Feb 2008 09:41:10 +0100 References: <001c01c87264$3c01b4e0$b4051ea0$@de> <698DE66518E7CA45812BD18E807866CE014A8D9D@us-ex1.zend.net> X-Mailer: Apple Mail (2.919.2) X-backendmedia-com-MailScanner-Information: Please contact the ISP for more information X-backendmedia-com-MailScanner: Found to be clean X-backendmedia-com-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=0.045, required 6, AWL 0.04) X-backendmedia-com-MailScanner-From: mls@pooteeweet.org X-Spam-Status: No Subject: Re: [PHP-DEV] RFC: Traits for PHP From: mls@pooteeweet.org (Lukas Kahwe Smith) On 21.02.2008, at 03:26, Andi Gutmans wrote: > a) > I think Traits should be able to act as a self-contained behavior > which can always be expected to work. For example if I want a > Counter behavior I would like that not to depend on the properties > in the containing class. While I don't think we should enable public > nor protected properties in Traits I think allowing for private > properties in Traits would come in very handy. It also is no problem > when it comes to mangling as we can use the Trait name. > > class Trait { > private $counter = 0; > function getNextSerialNumber() { > return $this->counter++; > } > } > > I strongly recommend not to support protected/public and not to even > get into the discussion of dealing with conflicts of such > properties. But I think private is very useful. Of course this could be nice, but I think this is maybe the point where one should move to delegate? > b) > I haven't thought this through completely but I think we may want to > consider a different model from supporting "removing" and "aliasing" > of functions. I think this can create a lot of complications > especially in larger works and it'll be write-once code and hard for > a newcomer to the code to really understand. > > I think the main reason to support removing/aliasing of functions is > in order to avoid conflicts with other Traits/Class methods. Maybe > what we can do is to have only "aliasing" but what it would do is to > create a public function with the new name and convert the old > function into a private function. > Benefits: > - Keeps the old code from running predictably without breaking > dependencies. > - Possibly even allowing some form of "is-a" relationship to > continue to be valid (and therefore the interface discussion may > even be resolved; at least to a certain level). In the case I faced > an is-a relationship (i.e. working instanceof operator) would have > been nice. I am probably not seeing the obvious here, but how does making the function private solve the naming collisions? regards, Lukas