Hi,

The above presents a problem if trait2 contains conflicting method
names, but a simple way to solve it would be to automatically alias
methods by prepending traitname::

<?php

trait trait1 { function a(){}}
trait trait2 { function a(){}}
class Blah extends ... implements ... traits trait1, trait2, trait3 {
}
?>

would create method "trait2::a" and we can alias it in the class body.

Also, $a->{'trait2::a'}(); is legal syntax, so no problems there.

Example:
<?php

trait trait1 { function a(){}}
trait trait2 { function a(){}}
class Blah extends ... implements ... traits trait1, trait2, trait3 {
    function trait2::a as b;
}
?>

This would be 100% obvious to me, and far clearer for reading since we
would be explicitly saying we're aliasing a function.
Could you please explain where in your proposal is the difference to the multiple inheritance available in C++? Think the auto-aliasing will lead to nothing else then multiple inheritance, with all its power and complexity.

One of the main problems here is the fragility, already pointed out be Joshua in its response from today.

Kind Regards

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

Reply via email to