Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35742 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66346 invoked by uid 1010); 23 Feb 2008 08:30:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 66331 invoked from network); 23 Feb 2008 08:30:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2008 08:30:30 -0000 Authentication-Results: pb1.pair.com header.from=andi@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=andi@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: andi@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:36564] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/A2-30812-4A9DFB74 for ; Sat, 23 Feb 2008 03:30:30 -0500 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 23 Feb 2008 10:30:35 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Sat, 23 Feb 2008 00:30:30 -0800 Message-ID: <698DE66518E7CA45812BD18E807866CE014A9358@us-ex1.zend.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PHP-DEV] RFC: Traits for PHP Thread-Index: Ach1d2DXQ+EVhLRTTZeDdn3uxtCmKgAfbjBw 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> <47BF0465.3080700@zend.com> To: "Stas Malyshev" , "Lukas Kahwe Smith" Cc: "Gregory Beaver" , "Marcus Boerger" , , "Evert|Rooftop" , X-OriginalArrivalTime: 23 Feb 2008 08:30:35.0500 (UTC) FILETIME=[5C89D2C0:01C875F6] Subject: RE: [PHP-DEV] RFC: Traits for PHP From: andi@zend.com ("Andi Gutmans") > -----Original Message----- > From: Stanislav Malyshev [mailto:stas@zend.com] > Sent: Friday, February 22, 2008 9:21 AM > To: Lukas Kahwe Smith > Cc: Gregory Beaver; Marcus Boerger; php@stefan-marr.de; Evert|Rooftop; > internals@lists.php.net > Subject: Re: [PHP-DEV] RFC: Traits for PHP >=20 > Hi! >=20 > > 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" >=20 > How you are going to do that? I think it's possible to do this but I haven't had time to dive deeper in the past couple of days. In my opinion the benefits of doing Traits in this way would be significant. You would still get the benefits of the original Traits proposal but it would provide stronger encapsulation and less potential for breakage (on par with typical OO polymorphism). In addition I really believe that enabling state is extremely important to make this a commonly useful feature (either via "private" or via a "local" like Stefan suggested). I won't be back at work until Tuesday but I will try and find some time to figure out if this can be implemented. I am pretty sure it can if during compilation of the Trait we mangle the properties&methods similar to private properties&methods using the Trait's name; and then when we flatten into a class then for the methods we expose we make sure the mangled methods use the new method's op_array. This should not be too hard and as Traits flattening does not require the same semantics as inheritance I think it should be quite doable. Bed time over here but I wanted to drop a short note so you didn't think I dropped of the face of the planet in the midst of this interesting discussion :) Andi