Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47569 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38510 invoked from network); 24 Mar 2010 16:58:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Mar 2010 16:58:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=jbondc@openmv.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jbondc@openmv.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain openmv.com from 64.15.152.204 cause and error) X-PHP-List-Original-Sender: jbondc@openmv.com X-Host-Fingerprint: 64.15.152.204 mail.ca.gdesolutions.com Received: from [64.15.152.204] ([64.15.152.204:51920] helo=mail.ca.gdesolutions.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 68/66-33174-6B44AAB4 for ; Wed, 24 Mar 2010 11:58:31 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 7C5325D7A; Wed, 24 Mar 2010 12:58:28 -0400 (EDT) X-Virus-Scanned: amavisd-new at gdesolutions.com Received: from mail.ca.gdesolutions.com ([127.0.0.1]) by localhost (mail.ca.gdesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16XFb3R-YO2L; Wed, 24 Mar 2010 12:58:28 -0400 (EDT) Received: from djbondc (modemcable083.208-56-74.mc.videotron.ca [74.56.208.83]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 062EE5D79; Wed, 24 Mar 2010 12:58:27 -0400 (EDT) To: "'Lukas Kahwe Smith'" , "'PHP Developers Mailing List'" References: <690D1362-7F1D-47B9-A4BF-EEA9CF38C5B0@pooteeweet.org> In-Reply-To: <690D1362-7F1D-47B9-A4BF-EEA9CF38C5B0@pooteeweet.org> Date: Wed, 24 Mar 2010 12:58:26 -0400 Message-ID: <001501cacb73$398c6420$aca52c60$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcrLQJfi1ZbdCTeeQX+Udsu3kpiQfAAJmM+Q Content-Language: en-ca x-cr-hashedpuzzle: AYe0 Atu6 BTgb Cu2M Dgc9 EKIs H8xj JOWJ J5k0 KQjc L+/g N438 VHhI WhyM XrLD X8Lk;2;aQBuAHQAZQByAG4AYQBsAHMAQABsAGkAcwB0AHMALgBwAGgAcAAuAG4AZQB0ADsAbQBsAHMAQABwAG8AbwB0AGUAZQB3AGUAZQB0AC4AbwByAGcA;Sosha1_v1;7;{B6E130BA-EBFD-42A8-9C5A-E2CC0DB4841F};agBiAG8AbgBkAGMAQABvAHAAZQBuAG0AdgAuAGMAbwBtAA==;Wed, 24 Mar 2010 16:58:19 GMT;UgBFADoAIABbAFAASABQAC0ARABFAFYAXQAgAGgAbwByAGkAegBvAG4AdABhAGwAIAByAGUAdQBzAGUAOgAgAHQAcgBhAGkAdABzACAAdgBzAC4AIABnAHIAYQBmAHQAcwA= x-cr-puzzleid: {B6E130BA-EBFD-42A8-9C5A-E2CC0DB4841F} Subject: RE: [PHP-DEV] horizontal reuse: traits vs. grafts From: jbondc@openmv.com ("Jonathan Bond-Caron") On Wed Mar 24 06:50 AM, Lukas Kahwe Smith wrote: > Ahoi, > > Thought it would be better to open up a new thread and also using the > term "horizontal reuse" in the subject so that we make it clearer that > there are actually two approaches. Here is the URL for Stefan's > proposal: > http://wiki.php.net/rfc/horizontalreuse > One thing I feel is missing from the RFC is how is_a() and instanceof are affected with traits or grafts. From: http://github.com/gron/php-src/blob/PHP_5_3-traits/Zend/tests/traits/languag e009.phpt class Foo { use C, A, B { B::foo instead A, C; } } $f = new Foo; echo is_a($f, 'A'); ? echo is_a($f, 'B'); ? It's seem to me that a defining a 'trait' should be advertised strictly as an 'advanced multiple inheritance technique' to reuse pieces of code and it shouldn't be considered as an object (grafts proposal). I don't like the "B::foo instead A, C" stuff though, so I agree with Lukas and find that Grafts are more intuitive / easy to learn. Personally, this syntax makes me happy but would keep the 'use' or 'with' keyword: http://wiki.php.net/rfc/nonbreakabletraits trait A { protected function foo() { echo 'a'; } } trait D { public function foo() { echo "d"; } function bar() { echo "d"; } } class Foo { use A; use D { function bar(); } } $f = new Foo; echo is_a($f, 'A'); // true echo is_a($f, 'D'); // false, since we've done an explicit selection/brackets: use D {} This is mainly userland feedback