Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47604 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46220 invoked from network); 25 Mar 2010 13:48:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Mar 2010 13:48:50 -0000 X-Host-Fingerprint: 217.114.211.68 unknown Date: Thu, 25 Mar 2010 08:48:50 -0500 Received: from [217.114.211.68] ([217.114.211.68:13227] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/03-31790-1C96BAB4 for ; Thu, 25 Mar 2010 08:48:50 -0500 To: internals@lists.php.net References: <690D1362-7F1D-47B9-A4BF-EEA9CF38C5B0@pooteeweet.org> <001601cacb74$0b037020$210a5060$@com> <9721DC06-BE10-49D0-BEDA-6B6FEB26B49D@stefan-marr.de> User-Agent: slrn/0.9.9p1 (SunOS) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: X-Posted-By: 217.114.211.68 Subject: Re: [PHP-DEV] horizontal reuse: traits vs. grafts From: dsp@php.net (David Soria Parra) 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" ? - David