Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40456 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25347 invoked from network); 11 Sep 2008 07:35:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Sep 2008 07:35:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=antoniadis@noodles.gr; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=antoniadis@noodles.gr; sender-id=unknown Received-SPF: error (pb1.pair.com: domain noodles.gr from 74.125.46.28 cause and error) X-PHP-List-Original-Sender: antoniadis@noodles.gr X-Host-Fingerprint: 74.125.46.28 yw-out-2324.google.com Received: from [74.125.46.28] ([74.125.46.28:26567] helo=yw-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/C0-30769-63AC8C84 for ; Thu, 11 Sep 2008 03:35:19 -0400 Received: by yw-out-2324.google.com with SMTP id 5so78380ywb.83 for ; Thu, 11 Sep 2008 00:35:16 -0700 (PDT) Received: by 10.65.248.18 with SMTP id a18mr3739912qbs.31.1221118516095; Thu, 11 Sep 2008 00:35:16 -0700 (PDT) Received: by 10.65.74.5 with HTTP; Thu, 11 Sep 2008 00:35:16 -0700 (PDT) Message-ID: <641f88250809110035w57abd979v657b6f187980c333@mail.gmail.com> Date: Thu, 11 Sep 2008 10:35:16 +0300 Sender: antoniadis@noodles.gr To: "Edward Z. Yang" Cc: internals@lists.php.net In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_58099_9510590.1221118516102" References: <005601c912e5$46a29280$d3e7b780$@com> X-Google-Sender-Auth: 36980a275f34fc7a Subject: Re: [PHP-DEV] PHP mixin RFC From: george@noodles.gr ("George Antoniadis") ------=_Part_58099_9510590.1221118516102 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Personally I think that traits is a lot safer than mixing classes.There will be a lot of things that will need to be considered in order to make it logical for developers to use. Quote from the RFC: "Any method or property that already exists in the class or parent/extended class cannot be changed unless using class_mixin() see below." I'm pretty sure this is against all beliefs in the php world. Runtime merging of classes and overriding methods is a no-no for me. Traits seems much more safe since you cannot initialize a trait and can only used to "flatter" other classes. The proposed way of mixins will create confusion when trying to continue development on an ongoing project and will need A LOT of extra documentation just for explaining the hierarchy of the mixed classes. A very simple case of mixins for php (that allready is implemented) can be seen in Advogato: Mixins for php. It has the following example. ******************************************* class Person { var $job = "person"; function show_job() { echo "Hi, I work as a {$this->job}."; } } class Bartender { var $job = "bartender"; function show_job() { echo "BARTENDER: "; Person::show_job(); } } $b = new Bartender; $b->show_job(); ************************************************** If you look at the example you can see that the Bartender class does NOT extend the Person class, but when using Person::show_job(); the person's method have access to the $b object's variables as if the bartender class extended the person class. IMO this is the safest way we can use mixins without getting into the troubles of creating too many (complicated) ways to do the same thing. G. On Thu, Sep 11, 2008 at 7:07 AM, Edward Z. Yang < edwardzyang@thewritingpot.com> wrote: > Jonathan Bond-Caron wrote: > > http://wiki.php.net/rfc/mixin > > It seems to me that class_mixin() is a bad idea for the core; it's more > of a runkit type functionality than traits. After all, we don't allow > dynamic inheritance, or dynamic interfaces... > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > ------=_Part_58099_9510590.1221118516102--