Hi Anthony:

I will not comment on the original question of this thread, but felt obliged to 
point out some details where my understanding differs from what I understand 
from your explanation. 

On 22 Oct 2011, at 07:25, Anthony Ferrara wrote:

> Well, I have a few opinions on this that I think are worth sharing:
> 
> 1. If this change is made, we no longer would have mixins, but would
> have regular multiple-inheritance (With all the "issues" associated
> with it).  Note that I said mixins and not traits.  That's because
> since these were implemented with state (member properties), they are
> not traits as implemented, but regular mixins. (Yet another gripe, but
> that's slightly off topic).

Please refer to: 
https://wiki.php.net/rfc/horizontalreuse#handling_of_propertiesstate

"Traits do not provide any provisioning for handling state."

What you observe is that PHP is a very dynamic language when it comes to the 
definition of fields.
And that is what traits also take into account. We do the minimal possible 
thing, to keep the WTF factor low, but there is no "real" support for state.
And as someone else pointed out: the main difference is indeed the difference 
between linear application (mixins) and order-less composition (traits).


> There's a much bigger problem though.  How would you solve the problem
> where a class uses a trait that implements an interface, but you don't
> pull one of the methods through (for example, you exclude it in the
> use clause)?

The relevant part of the RFC: 
https://wiki.php.net/rfc/horizontalreuse#conflict_resolution

We abandoned the idea of an explicit exclude operator long ago. (I think it was 
never in the PHP SVN.)
Thus, the situation you describe cannot occur in the sense that a method is 
missing from the class.
However, you can of course provide incompatible method implementations. (Which 
does not make traits any different from any other way to implement an 
interface.) 

Best regards
Stefan


-- 
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to