Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35730 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35070 invoked by uid 1010); 22 Feb 2008 15:33:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35055 invoked from network); 22 Feb 2008 15:33:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2008 15:33:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=david.coallier@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=david.coallier@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.146.183 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.146.183 wa-out-1112.google.com Received: from [209.85.146.183] ([209.85.146.183:61509] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/52-22931-B3BEEB74 for ; Fri, 22 Feb 2008 10:33:18 -0500 Received: by wa-out-1112.google.com with SMTP id l24so473006waf.17 for ; Fri, 22 Feb 2008 07:33:12 -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=CmzlxSNhuoD2f3h2adMyukNgEhix4B3zrA6nUfIfYj4=; b=FZN/3Z7QktIdi0H4cBoCd4xN1K7vSc+c2g3oabbETZCoa9rjW22xmoV+KWm+L+8gvz4SAt78ASTPTES4NRzIPg6rNO2yed/iH3QbxgEgy2ATiHeT+VxJc32ijEOf+3CQ2gkpcOl64yObO3VpM3VinnQnxrQjoiqN4O5mahZ0jGc= 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=npBgZoZVqo3sQnA6bb/HqGhZ2hOVVR1LYFiI3OI+/3jQYAUs6xMAh6elOewjdDywxwAGWiSBpB/dxCva9RjjZSbTCUm4yYin843SxKgFgTfTsvX42qLUZwPuvvVBlxY2c1+NJS3nkDrcO8Z4LHFVeYeBcdxNagDgla+vwV3Y174= Received: by 10.114.61.1 with SMTP id j1mr97118waa.62.1203694392154; Fri, 22 Feb 2008 07:33:12 -0800 (PST) Received: by 10.114.13.11 with HTTP; Fri, 22 Feb 2008 07:33:12 -0800 (PST) Message-ID: Date: Fri, 22 Feb 2008 10:33:12 -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> <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: 7912d9097f844a3a Subject: Re: [PHP-DEV] RFC: Traits for PHP From: davidc@php.net ("David Coallier") On Fri, Feb 22, 2008 at 10:32 AM, David Coallier wrote: > > 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; It is of course remove One::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. > -- David, Re-read what you are replying.