Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77680 invoked from network); 17 Apr 2009 17:20:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2009 17:20:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain punkave.com from 209.85.217.159 cause and error) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.217.159 mail-gx0-f159.google.com Received: from [209.85.217.159] ([209.85.217.159:62867] helo=mail-gx0-f159.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/72-25341-26AB8E94 for ; Fri, 17 Apr 2009 13:20:35 -0400 Received: by gxk3 with SMTP id 3so97693gxk.23 for ; Fri, 17 Apr 2009 10:20:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.34.5 with SMTP id j5mr2635111ibd.31.1239988830262; Fri, 17 Apr 2009 10:20:30 -0700 (PDT) In-Reply-To: <52F25C37-F12D-4A85-A7D3-C579637B56C5@stefan-marr.de> References: <52F25C37-F12D-4A85-A7D3-C579637B56C5@stefan-marr.de> Date: Fri, 17 Apr 2009 13:20:30 -0400 Message-ID: To: Stefan Marr Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Grafts, Traits, horizontal reuse From: tom@punkave.com (Tom Boutell) On Fri, Apr 17, 2009 at 10:16 AM, Stefan Marr wrote: > For the sake of simplicity, we might discuss a very basic solution. > It would be possible to introduce trait-local state only. > Thus, all properties defined in a trait are only available within methods of the same trait, > no other operations are able to access these properties. Yes, I think this is exactly right. Programmers who want to expose the state can do that by writing setters and getters. A trivial inconvenience compared to the pain of not being able to have multiple enhancements of the same third party class from multiple sources - something that comes up almost immediately when you start talking about plug-ins for frameworks. > How ever, there are also corner cases. (Behavior might be different in case > of name clashes for dynamically created properties within a composition, > changing behavior depending on the order of method invocations on a single > object) I'm not sure I grasp how these can happen in this scenario. > Just to be clear, there is no such thing like renaming. Renaming is just not > possible with a dynamic language like PHP. ($this->$bar = 'baz'; > $this->$foo();... ) OK, but with strictly-trait-local state this is not an issue. A shame this can't be in 5.3 but we will get there. (: -- Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com