Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47606 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58891 invoked from network); 25 Mar 2010 15:00:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Mar 2010 15:00:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=mls@pooteeweet.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mls@pooteeweet.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pooteeweet.org from 188.40.37.16 cause and error) X-PHP-List-Original-Sender: mls@pooteeweet.org X-Host-Fingerprint: 188.40.37.16 hq1.backendmedia.com Linux 2.6 Received: from [188.40.37.16] ([188.40.37.16:43202] helo=hq1.backendmedia.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/45-31790-19A7BAB4 for ; Thu, 25 Mar 2010 10:00:34 -0500 Received: from localhost (unknown [127.0.0.1]) by hq1.backendmedia.com (Postfix) with ESMTP id 2C62A2E3000F; Thu, 25 Mar 2010 15:00:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at backendmedia.com Received: from hq1.backendmedia.com ([127.0.0.1]) by localhost (hq1.backendmedia.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w7rMlnOGgKff; Thu, 25 Mar 2010 16:00:29 +0100 (CET) Received: from [192.168.0.151] (217-162-131-234.dclient.hispeed.ch [217.162.131.234]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: mls@pooteeweet.org) by hq1.backendmedia.com (Postfix) with ESMTPSA id 32FD22E3000E; Thu, 25 Mar 2010 16:00:29 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii In-Reply-To: Date: Thu, 25 Mar 2010 16:00:25 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <5EE73B98-FC94-4110-BA74-189B547A7ED5@pooteeweet.org> References: <690D1362-7F1D-47B9-A4BF-EEA9CF38C5B0@pooteeweet.org> <001601cacb74$0b037020$210a5060$@com> <9721DC06-BE10-49D0-BEDA-6B6FEB26B49D@stefan-marr.de> To: David Soria Parra X-Mailer: Apple Mail (2.1077) Subject: Re: [PHP-DEV] horizontal reuse: traits vs. grafts From: mls@pooteeweet.org (Lukas Kahwe Smith) 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) >=20 > Scala offers stackable traits so that you can mixin traits during = object creation. > An example: >=20 > trait Philosophical { > public function think () { > echo "Cogito ergo sum"; > } > }=20 >=20 > trait Drink { > public function drink () { > echo "gluck gluck" > } > } >=20 > $obj =3D new Person(); >=20 > $obj->think(); // will fail >=20 > $obj =3D new Person() with Philosophical; > $obj->think(); // works >=20 > $obj =3D new Person() with Philsophical, Drink; > $obj->drink(); // works > $obj->think(); // works >=20 > 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. >=20 > But as said just a general idea that I might try to work on once = traits are comittet. >=20 > Stefan what do you think about "stackable traits" ? Woha .. that code really scares me. regards, Lukas Kahwe Smith mls@pooteeweet.org