Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63326 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23128 invoked from network); 10 Oct 2012 13:58:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2012 13:58:48 -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.41 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 74.115.204.41 relay-hub205.domainlocalhost.com Received: from [74.115.204.41] ([74.115.204.41:29553] helo=relay-hub205.domainlocalhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/16-23031-21F75705 for ; Wed, 10 Oct 2012 09:58:48 -0400 Received: from MBX202.domain.local ([169.254.169.44]) by HUB205.domain.local ([192.168.68.49]) with mapi id 14.02.0283.003; Wed, 10 Oct 2012 09:57:59 -0400 To: Nikita Popov CC: Jazzer Dane , Leigh , =?iso-8859-1?Q?Johannes_Schl=FCter_=28johannes=40schlueters=2Ede=29?= , "Rasmus Schultz (rasmus@mindplay.dk)" , "Etienne Kneuss (colder@php.net)" , "Nikita Popov (nikita.ppv@googlemail.com)" , "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] Propety Accessors v1.1 Thread-Index: Ac2lRqaw0wLAVcGGQAyyWuaNO91x4QBHSfMAABNVRgAAB5uHkAAPDrAAAAc75gA= Date: Wed, 10 Oct 2012 13:57:58 +0000 Message-ID: <9570D903A3BECE4092E924C2985CE485612B4BE3@MBX202.domain.local> References: <9570D903A3BECE4092E924C2985CE485612B3B48@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B496D@MBX202.domain.local> 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 Wed, Oct 10, 2012 at 5:51 AM, Clint Priest wrote= : > > I'm not even sure that automatic backing fields are even desired, I > > never felt the need to have them in C# and the only reason they were > > included is because they were a part of Dennis's original proposal. > > Eliminating them would eliminate this as an issue. >=20 > I just did a bit of research regarding this topic and I have found the fo= llowing reasons why automatic properties exist in C#: > 1. Changing a field to a property breaks the binary interface, so all cod= e using the library has to be recompiled. If you are using an > automatic property you can safely add additional behavior for it later. > 2. Properties support data binding, whereas fields do not. > 3. There are attributes that work for properties, but don't work for fiel= ds. > 4. Reflection for fields and properties works differently, so changing a = field to a property is a BC break. >=20 > I guess that #1 is the most important one (you don't want to break the > interface) and it obviously does not apply to PHP. Points #2 and #3 also = don't apply as PHP has neither data binding not attributes. #4 > also doesn't seem to apply because ReflectionPropertyAccessor defines all= the methods that ReflectionProperty defines, so > changing > field->property should be okay there too. >=20 > From that I would conclude that the automatic properties are really not n= eeded in PHP. I think they will only cause confusion as to > when one should use `public $name;` and when one should use `public $name= { get; set; };`. >=20 > The only thing I'm not sure about is how read-only / write-only propertie= s rely on automatic properties with your current > implementation. If the automatic properties aren't needed there either, t= hen I think they can be safely removed. Nice, I would agree that we should eliminate the automatic get/set since th= e reason they exist in C# is not an issue in PHP and it has only served to = confuse everyone. With the read-only and write-only, they are separate from automatic getters= /setters really. If you define a read-only with {get;} it's the same as an= y other getter.