On 25.03.2010, at 14:48, David Soria Parra wrote:
> Just as a general idea (which is certainly something after traits are
> implemented once)
>
> Scala offers stackable traits so that you can mixin traits during object
> creation.
> An example:
>
> trait Philosophical {
> public function think () {
> echo "Cogito ergo sum";
> }
> }
>
> trait Drink {
> public function drink () {
> echo "gluck gluck"
> }
> }
>
> $obj = new Person();
>
> $obj->think(); // will fail
>
> $obj = new Person() with Philosophical;
> $obj->think(); // works
>
> $obj = new Person() with Philsophical, Drink;
> $obj->drink(); // works
> $obj->think(); // works
>
> This approach is taken in scala and works pretty fine there for composing
> classes
> during runtime and should be douable in PHP too. For sure aliasing is not
> possible in this example.
>
> But as said just a general idea that I might try to work on once traits are
> comittet.
>
> Stefan what do you think about "stackable traits" ?
Woha .. that code really scares me.
regards,
Lukas Kahwe Smith
[email protected]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php