Re: RFC: Traits for PHP
| From: | Stefan Marr | Date: | Sat, 23 Feb 2008 19:25:29 +0000 |
| Subject: | Re: RFC: Traits for PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35758@lists.php.net to get a copy of this message | ||
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 {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 Regardsfunction 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++?