On Thu, Oct 15, 2009 at 10:42 AM, Stefan Marr <p...@stefan-marr.de> wrote:
> Hi:
>
> On 14 Oct 2009, at 22:44, Tom Boutell wrote:
>
>> I'm very concerned about the practical consequences of introducing
>> traits without state.
>
> Well, we have not found a sufficient design until now, which would fit
> nicely into PHP from dynamic and simplicity perspective.

Could you elaborate a little? I'm having trouble understanding why we
can't just implement trait properties according to exactly the same
policy we're using for methods with regard to conflict
resolution/renaming and all the rest of it.

>> B. PHP allows you to define properties at runtime. That is, you can write:
>>
>> $this->title = 'my title';
>>
>> Without declaring var $title; at the class level.
>
> Thats the currently preferred approach from my perspective.
> The only thing you are going to lose here is a notion of separation of state
> from different traits, compared to a language supported approach.
>
> However, if you prefer to be more strict, it is still perfectly possible to
> circumvent this problem by using getters and setters.

So the trait would continue to use this tactic (runtime assignment to
previously undeclared properties) internally, and wrap that in getters
and setters...

Will PHP ever include optional warnings for the use of undeclared
properties? If so, then it doesn't make sense to also institutionalize
their use as the only right way to have state in traits.

-- 
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to