On 1/3/13 11:41 AM, Clint Priest wrote:
class Foo {
private $realbar;
public $bar = 2 {
get { return $this->realbar; }
set { $this->realbar = $value; }
}
}
What would be the point of this?
I think it would be more readable for someone using the class. As a user it helps to know
the default of the property I'll actually be interacting with. In a non-trivial getter the
default may be much harder to tease out.
But yes, I agree that it's straightforward enough for the class author to set defaults as
needed, so I see no problem moving forward. The RFC should make clear that only the shadow
value is set (a setter, if present, is not used).
In the features docs I suggest finding a term for a non-traditional property, like
"guarded property".
Also I think you should eliminate all "shadowing" language. IMO it adds more confusion
than it removes. Here's some language that may/may not be useful:
Almost all interaction with a guarded property is "proxied", meaning the getter and setter
methods are used instead of direct reading/writing of the value. There are only two
exceptions:
1. Within a getter's scope, reads are not proxied: the property is read
directly.
2. Within a setter's scope, writes are not proxied; the property is written to
directly.
Accessors are free to interact with other properties which are visible to them, but access
to other guarded properties is always proxied.
Accessors are not required to use the property value, but it always exists.
Steve Clay
--
http://www.mrclay.org/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php