> On 10 October 2012 01:16, Johannes Schlüter <johan...@schlueters.de> wrote: > > Up until now reflection is leaky and is telling the truth. We should > > either keep that or completely clean up reflection. > > Reflection should always tell the truth, or there is no point in it. >
Unfortunately the "truth" here is subjective. Does the PHP programmer need the "truth of underlying language implementation details" or do they need the "truth" of what they've defined? I would argue that if the PHP programmer has defined a property accessor then the truth to him/her is that it's a property accessor and should be "reflected" as such. The fact that the underlying php language implements it internally as a series of functions isn't relevant and is a distortion of the truth, from the perspective of the PHP programmer. > On 10 October 2012 04:28, David Muir <davidkm...@gmail.com> wrote: > > That said, it wouldn't help for scalar values, and that leads to a > > problem with the current syntax (AFAICS). You can't specify the > > initial value for a > > property: > > This is one of the points I was trying to get across, there is currently no > way to set the default value*. If your setter performs some > sort of calculation on the value, then you're going to have to reverse that > process in order to set the initial value constructor. > > *Unless you use the following highly confusing approach. > > class MyClass { > protected $__property = 'default'; > > public $property { > get; > } > } > > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: > http://www.php.net/unsub.php Property accessors are not properties, they do not have their own data storage "memory space." Let's take a big example here, lets expand on the TimePeriod class... class TimePeriod { private $_Seconds = 600; public $Seconds { get { return $this->_Seconds; } set { $this->_Seconds = $value; } } public $Minutes { get { return $this->Seconds / 60; } set { $this->Seconds = $value * 60; } } public $Hours { get { return $this->Seconds / 3600; } set { $this->Seconds = $value * 3600; } } public $Days { ... } public $Weeks { ... } public $Months { ... } public $Years { ... } public $Decades { ... } public $Centuries { ... } } Now, this class's data space is one variable ($_Seconds), if we were to some-how deviate from (afaik) every other language which implements property accessors and create a "memory space" for every property accessor (none of which would be used by the above code), this classes data space now becomes 10 variables, only 1 of which is used. I'll take this example to another language many people should be familiar with, Javascript: { _Seconds: 600, get Seconds() { return this._Seconds; }, get Minutes() { return this._Seconds / 60; } get Hours() { return this._Seconds / 3600; } ... } These 'getters' do not get their own memory space allocated, they *are not* properties, they are getters. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php