Re: Grafts, Traits, horizontal reuse

From: Date: Fri, 17 Apr 2009 17:20:30 +0000
Subject: Re: Grafts, Traits, horizontal reuse
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-43726@lists.php.net to get a copy of this message
On Fri, Apr 17, 2009 at 10:16 AM, Stefan Marr <php@stefan-marr.de> 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

« previous php.internals (#43726) next »