Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63324 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18911 invoked from network); 10 Oct 2012 13:22:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2012 13:22:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:39684] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/55-23031-E8675705 for ; Wed, 10 Oct 2012 09:22:23 -0400 Received: by mail-lb0-f170.google.com with SMTP id gm13so417647lbb.29 for ; Wed, 10 Oct 2012 06:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=xaCHc5ujrZ49K1Zep4m/tA1VrDIdLcsw5VOoAcm8GNo=; b=xrgSfYMC/Y9CA9JK3sCQj7TU8GOj2oJnmXQABQadfyn6Y4z/6GpL72qtxCTMkHVN2i 1/dJZphSusKbg6oISmGWap0w/L8zs9lwR/jN72Ce1ORwrrLs66sXra4L1BSlC1a3sN61 Tj1EVU/ASL5Cpp1jNTOUqT+L9IkE2bMu73/w7Lt/wzHq0I6++7SsOna6/ZuJKUP9BFOo EDQrl6TG2lcouSx/K3lLWBlXqZPuyDB7Zosr3s2V7eF5bGXdmcrsWQ7IaEAw8q1WY2wz N495E/9tkRqpzoMYefdPR3LciJVBNHf2NDxLsA9lPPHshHnbzD23HQNLifVf0PMk6e/w Bksw== MIME-Version: 1.0 Received: by 10.112.82.33 with SMTP id f1mr40531lby.121.1349875339232; Wed, 10 Oct 2012 06:22:19 -0700 (PDT) Received: by 10.112.83.100 with HTTP; Wed, 10 Oct 2012 06:22:18 -0700 (PDT) In-Reply-To: <9570D903A3BECE4092E924C2985CE485612B496D@MBX202.domain.local> References: <9570D903A3BECE4092E924C2985CE485612B3B48@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B496D@MBX202.domain.local> Date: Wed, 10 Oct 2012 15:22:18 +0200 Message-ID: To: Clint Priest 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" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Propety Accessors v1.1 From: nikita.ppv@gmail.com (Nikita Popov) 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. I just did a bit of research regarding this topic and I have found the following reasons why automatic properties exist in C#: 1. Changing a field to a property breaks the binary interface, so all code 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 fields. 4. Reflection for fields and properties works differently, so changing a field to a property is a BC break. 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. From that I would conclude that the automatic properties are really not needed 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; };`. The only thing I'm not sure about is how read-only / write-only properties rely on automatic properties with your current implementation. If the automatic properties aren't needed there either, then I think they can be safely removed. Nikita