Hi Richard:

On 13 Dec 2010, at 14:13, Richard Quadling wrote:

> From the rfc [1], "A Trait is similar to a class, but only intended to
> group functionality".
> 
> I'm guessing that says it all. A trait has no properties.

It is really a practical concern of language consistency for the moment.
I am not talking about any fancy new language feature to handle state.

At the moment, I am just concerned with examples like the following:

trait Foo {
  function bar() {
    $this->baz = 'abcd';
  }
}

If that example becomes more complex, I would consider it to be good software 
engineering practice to document the usage of $this->baz and its semantic.

For classes this is usually done by explicitly naming the property in the class 
body.

At the moment, there is nothing which hinders you in doing that for a trait.

However, since traits do not provide any safety provisioning for state, i.e., 
there is no collision handling for properties, the question is, how do we 
either promote to use explicit accessors or how do we deal with the inevitable 
and certainly justified use of properties in one or the other way.

Best regards
Stefan

-- 
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525


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

Reply via email to