"Stefan Marr" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> jvlad schrieb:
>> in other words, why to introduce such a new thing as trait instead of 
>> using classes and trait'ing them?
> I've introduced it as a separate notion from classes to avoid 
> misconception and problems occurring from conflicting properties and 
> constant definitions.
>
> Your example demonstrates the week point of this approach very well in my 
> eyes. Instead of allow easy reuse, you will have to manage much more 
> conflicts. Think it is better to restrict the idea. Just allow to reuse 
> methods trying to avoid additional conflicts which must be handled each 
> time.
>
> Another point is, think there is no benefit in duplicating constants?.

Why would this create any problems? Say, you have class B that extends class 
A and both do define one method and one property under the same names. Will 
this create a problem? No. It's because there are rules that clearly 
describe how it works (method and property will be overriden). Similar 
approach may be applied to trait'ing classes. Why not? For example if you 
have a property defined above trait'ing, it will be overriden by the trait 
if it comes up with its own property with the same name (same goes for the 
properties defined in the ancestor class). If trait defines a property, it 
can be overriden by class if it introduce it below trait'ing statement.
On the other hand, if someone being a developer cares of potential 
"conflict" (unwanted override), he/she may simply not define properties and 
constants in the class that's intended to be trait'ed into another class.


Best Regards
j 

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

Reply via email to