Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63319 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6444 invoked from network); 10 Oct 2012 11:53:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2012 11:53:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=cpriest@zerocue.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cpriest@zerocue.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zerocue.com designates 74.115.204.40 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 74.115.204.40 relay-hub204.domainlocalhost.com Received: from [74.115.204.40] ([74.115.204.40:47035] helo=relay-hub204.domainlocalhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/E2-23031-BC165705 for ; Wed, 10 Oct 2012 07:53:51 -0400 Received: from MBX202.domain.local ([169.254.169.44]) by HUB204.domain.local ([192.168.68.48]) with mapi id 14.02.0283.003; Wed, 10 Oct 2012 07:53:05 -0400 To: Leigh , David Muir CC: "johannes@schlueters.de" , "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] Propety Accessors v1.1 Thread-Index: Ac2lRqaw0wLAVcGGQAyyWuaNO91x4QAa3KSAAASYmIAAAETYgAAAKxAAAAVw6sAABDgWAAACiuryADB17oAADHRmAAADrDWQ Date: Wed, 10 Oct 2012 11:53:04 +0000 Message-ID: <9570D903A3BECE4092E924C2985CE485612B4ABE@MBX202.domain.local> References: <9570D903A3BECE4092E924C2985CE485612B3B48@MBX202.domain.local> <5073328D.5000002@gmail.com> <50735165.8010703@aaronholmes.net> <9570D903A3BECE4092E924C2985CE485612B4353@MBX202.domain.local> <760ab4f994a78a846cf86aafda71e0e2@mohiva.com> <5074EB6F.4030809@gmail.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.64.21] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: [PHP-DEV] [RFC] Propety Accessors v1.1 From: cpriest@zerocue.com (Clint Priest) > On 10 October 2012 01:16, Johannes Schl=FCter wr= ote: > > Up until now reflection is leaky and is telling the truth. We should > > either keep that or completely clean up reflection. >=20 > Reflection should always tell the truth, or there is no point in it. >=20 Unfortunately the "truth" here is subjective. =20 Does the PHP programmer need the "truth of underlying language implementati= on details" or do they need the "truth" of what they've defined? =20 I would argue that if the PHP programmer has defined a property accessor th= en the truth to him/her is that it's a property accessor and should be "ref= lected" as such. The fact that the underlying php language implements it i= nternally as a series of functions isn't relevant and is a distortion of th= e truth, from the perspective of the PHP programmer. > On 10 October 2012 04:28, David Muir 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: >=20 > 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 th= at process in order to set the initial value constructor. >=20 > *Unless you use the following highly confusing approach. >=20 > class MyClass { > protected $__property =3D 'default'; >=20 > public $property { > get; > } > } >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visi= t: http://www.php.net/unsub.php Property accessors are not properties, they do not have their own data stor= age "memory space." Let's take a big example here, lets expand on the TimePeriod class... class TimePeriod { private $_Seconds =3D 600; public $Seconds { get { return $this->_Seconds; } set { $this->_Seconds =3D $value; } } public $Minutes { get { return $this->Seconds / 60; } set { $this->Seconds =3D $value * 60; } } public $Hours { get { return $this->Seconds / 3600; } set { $this->Seconds =3D $value * 3600; }=20 } 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 som= e-how deviate from (afaik) every other language which implements property a= ccessors and create a "memory space" for every property accessor (none of w= hich 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 w= ith, 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.