Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14019 invoked by uid 1010); 22 Feb 2008 15:04:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 14002 invoked from network); 22 Feb 2008 15:04:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2008 15:04:26 -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:58438] helo=serveforce1.backendmedia.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/AE-22931-874EEB74 for ; Fri, 22 Feb 2008 10:04:25 -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 8951C12241A8; Fri, 22 Feb 2008 16:05:04 +0100 (CET) Cc: Marcus Boerger , php@stefan-marr.de, Evert|Rooftop , Stanislav Malyshev , internals@lists.php.net Message-ID: To: Gregory Beaver In-Reply-To: <47BEE001.9080602@chiaraquartet.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: Fri, 22 Feb 2008 16:03:37 +0100 References: <001c01c87264$3c01b4e0$b4051ea0$@de> <173732199.20080219175837@marcus-boerger.de> <1203452909.24580.9.camel@localhost> <1e12984d0802191323o710c6b8ej3a54af7901cf35f1@mail.gmail.com> <47BB4AC9.9070701@zend.com> <1e12984d0802191346x7c145d7fp14c01ec4e5993779@mail.gmail.com> <47BB4F49.1030904@rooftopsolutions.nl> <1e12984d0802191359p4f21c3acrdff4b86adfb4bf3@mail.gmail.com> <1495054633.20080220205951@marcus-boerger.de> <1e12984d0802201243gfa51f01i311891e8965ed51e@mail.gmail.com> <9EE7F229-0710-48E8-9A26-DC8031AF8979@pooteeweet.org> <1985981545.20080222134413@marcus-boerger.de> <47BEE001.9080602@chiaraquartet.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.044, 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 22.02.2008, at 15:45, Gregory Beaver wrote: > Marcus Boerger wrote: >> Hello Lukas, >> >> alright, >> >> 'foo as bar' is ok to me and does not even add a new keyword. >> Ignore or any more keywords are bad and I also think that the correct >> would be hide(ing). But as I further more explained it should >> really be >> something that only marks a method as private if at all. That can be >> done as: >> 'foo as private' since private is a keyword it cannot conflice >> anyway. > > I like this solution. Yes to me it seems like we can solve the entire "lack of encapsulation" through aliasing/hiding by making the following changes to the original proposal: A trait may contain methods and properties. When importing a trait into a class, all methods and properties are imported in a way that makes them only visible within the trait (I dont like the use of "private" here .. its what confused me in the first proposals of this approach by Marcus/Andi). The user of the trait can however explicitly make properties and methods from the trait visible to the class importing the trait. Also the trait using class can explicitly say that it wants to override a method/property in the scope of the trait. This way: 1) there is little chance of accidentally breaking a trait 2) changes within the trait should not break anything in the trait using class, unless the developer explicitly messed with the traits internals in the class using the trait. in that case however he can quickly spot the potentially problematic lines > I have been uncomfortable with the current trait suggestions because > they occur in the body of the class, whereas extends/implements is > outside. I think there is a way to handle this, however. I dont agree here. traits are different. They do not affect "what" the class is. They change what it can do and as such the stuff should be defined next to properties and methods. > > > trait trait1 { function a(){}} > trait trait2 { function a(){}} > class Blah extends ... implements ... traits trait1, trait2, trait3 { > } > ?> Here it gets worse. Now if I refactor things into a trait, I have to start changing all uses of those methods. @Greg: I think you are going in the wrong direction here. regards, Lukas