> -----Original Message----- > From: Stanislav Malyshev [mailto:[EMAIL PROTECTED] > Sent: Friday, February 22, 2008 9:21 AM > To: Lukas Kahwe Smith > Cc: Gregory Beaver; Marcus Boerger; [EMAIL PROTECTED]; Evert|Rooftop; > internals@lists.php.net > Subject: Re: [PHP-DEV] RFC: Traits for PHP > > Hi! > > > 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" > > 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php