Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35729 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34174 invoked by uid 1010); 22 Feb 2008 15:32:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34159 invoked from network); 22 Feb 2008 15:32:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2008 15:32:41 -0000 Authentication-Results: pb1.pair.com header.from=david.coallier@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=david.coallier@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.162.177 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: david.coallier@gmail.com X-Host-Fingerprint: 209.85.162.177 el-out-1112.google.com Linux 2.4/2.6 Received: from [209.85.162.177] ([209.85.162.177:54141] helo=el-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/32-22931-91BEEB74 for ; Fri, 22 Feb 2008 10:32:41 -0500 Received: by el-out-1112.google.com with SMTP id n30so402088elf.17 for ; Fri, 22 Feb 2008 07:32:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=r0WEaBv8L2fx/FkKsAKw0U4A1mOVBUqNKM+IppHkpLY=; b=mu7NklYNwMER6NrEWkQLMg2DUFu9VEkatAuf8HWWh/G3yuXftchAm5l7lCtwVTk/L02NRhzbFUMRA56bWLGcjJb38dCqOJEWj/WIu+EORlpV1AhJP/94Tx/6GIxPw1ld31jKiHPIaG78ow8rAZFAHkwas/f6MAeFDibR1osBu/c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=R5m6a6OEJlyc8PpmHhsnyGdtl0ZfIbY5SBbQK2wMQwBVPEr4E7BOpstX69dIvBCp/OY4N1KP2iuU1rQo/+OR3/OgUwXMP/SLtnAhY4Av0WcA98dXATPs1LkSX1GnEBxxEXWKw59J+mM5PYxfgyAklxyXSUw6bBj6m04wz87uucw= Received: by 10.114.149.2 with SMTP id w2mr128861wad.5.1203694358040; Fri, 22 Feb 2008 07:32:38 -0800 (PST) Received: by 10.114.13.11 with HTTP; Fri, 22 Feb 2008 07:32:37 -0800 (PST) Message-ID: Date: Fri, 22 Feb 2008 10:32:37 -0500 Sender: david.coallier@gmail.com To: "Lukas Kahwe Smith" Cc: "Gregory Beaver" , "Marcus Boerger" , php@stefan-marr.de, Evert|Rooftop , "Stanislav Malyshev" , internals@lists.php.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <001c01c87264$3c01b4e0$b4051ea0$@de> <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-Google-Sender-Auth: 1aa36e98e8ad4e99 Subject: Re: [PHP-DEV] RFC: Traits for PHP From: davidc@php.net ("David Coallier") On Fri, Feb 22, 2008 at 10:03 AM, Lukas Kahwe Smith wrote: > > 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. > Fun that you mentionned that structure greg because I was thinking of something along those lines. Something very similar actually but the aliasing could look like this: trait One { function name() { return __TRAIT__; } function removeMe() {} } trait Two { function name() { return __TRAIT__; } } class Reel traits One, Two { override One::name with Two::name; remove Two::removeMe; } $object = new Reel(); echo $object->name(); // Echos "Two" of course. I find that rather clean and clear that you we are either overriding what with what and then removing a method. But as lukas mentionned, we may be stepping out of line here... > regards, > Lukas > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- David, Re-read what you are replying.