Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2261 invoked from network); 26 Mar 2010 09:26:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Mar 2010 09:26:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=mathieu.suen@easyflirt.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mathieu.suen@easyflirt.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain easyflirt.com designates 91.199.255.56 as permitted sender) X-PHP-List-Original-Sender: mathieu.suen@easyflirt.com X-Host-Fingerprint: 91.199.255.56 python-06.easyrencontre.com Linux 2.6 Received: from [91.199.255.56] ([91.199.255.56:43334] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/E1-26248-ECD7CAB4 for ; Fri, 26 Mar 2010 04:26:39 -0500 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id AD0C46374DC; Fri, 26 Mar 2010 10:26:35 +0100 (CET) Message-ID: <4BAC7DCA.2070508@easyflirt.com> Date: Fri, 26 Mar 2010 10:26:34 +0100 User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Stefan Marr CC: Lukas Kahwe Smith , David Soria Parra , internals@lists.php.net References: <690D1362-7F1D-47B9-A4BF-EEA9CF38C5B0@pooteeweet.org> <001601cacb74$0b037020$210a5060$@com> <9721DC06-BE10-49D0-BEDA-6B6FEB26B49D@stefan-marr.de> <5EE73B98-FC94-4110-BA74-189B547A7ED5@pooteeweet.org> <87B0F854-BB82-4125-84A4-34BD93049760@pooteeweet.org> <0168C42F-EDBC-48D2-B253-F452E3E67B81@stefan-marr.de> In-Reply-To: <0168C42F-EDBC-48D2-B253-F452E3E67B81@stefan-marr.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] horizontal reuse: traits vs. grafts From: mathieu.suen@easyflirt.com ("mathieu.suen") Stefan Marr wrote: > On 25 Mar 2010, at 21:30, Stefan Marr wrote: > >> On 25 Mar 2010, at 16:37, Lukas Kahwe Smith wrote: >> >>> Hi, >>> >>> this was just brought up on IRC. my understanding is that traits have no concept of properties, but grafts do (all hidden internally). correct? >>> >> Right, the Traits proposal as it is at the moment, avoids the explicit discussion of state. >> This is not a restriction per se, but could limit the composability of traits. >> >> To ensure composibility, you would have to resort to abstract methods which are implemented by the composing class. >> > Maybe I should clarify that. > > Currently the semantics is implicitly the following: > > class Base{ > var $a; > } > > trait T1 { > var $a; > var $b; > } > > trait T2 { > var $a; > var $c; > } > > class Composite extends Base { > use T1, T2; > } > > and Composite would have the instance variables $a, $b, $c. > The problem would be of course that Base, T1, and T2 could use $a for completely different things. > > Simple, but at the cost of composability/safety. > But for most practical cases that should be 'good enough'. As already mentioned, if you want stronger guarantees, state accessor methods can be used. > > However, I think this implication is not discussed in the RFC, and works just because PHP can create the fields dynamically. Thus, I used 'var' here in the example, instead of defining a semantics and handling for public, private, protected. > > Best regards > Stefan Variable has been discuss in *http://tinyurl.com/y9t7nd9 --Mathieu Suen *