Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63557 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23566 invoked from network); 20 Oct 2012 09:52:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Oct 2012 09:52:29 -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.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:56842] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/3D-22055-C5472805 for ; Sat, 20 Oct 2012 05:52:29 -0400 Received: by mail-la0-f42.google.com with SMTP id e6so794641lah.29 for ; Sat, 20 Oct 2012 02:52:25 -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=rsT+53pl6B7uv/O4ek2jebi5C4VWLGpdEHtXhzGH0xU=; b=wVxTv8S359Fc2cX5XEUGAJdtQnT+GyI1afCBJCb78TjbcgvtFyJX9zgENQZ0ZXO0z6 W0IIKv0GxqsSUEsjw+XPaUAsz1Rz+phwTIYJHKzW1BMhkIaN9BWj2jncKNJLSUAYy9QO XPTqYckxAkoE0jalPw5jORR2eCSSYvtz0cdfszPXlNoN7wJGGBj7UQYXzp8zrt5rVixQ o37Xg35YUyLT1GqV0KqPazdZqWpLgA08K1SVyy//vBE5XMirUB+ZnrWgv3YslBt6UiAE B49RQ0giMsdWCH+g+HwaHq88gVZIrE/CyYc0hS3d1HQzyucKVNIQYF6Q7X7BHytZhXIL V4Yg== MIME-Version: 1.0 Received: by 10.152.148.169 with SMTP id tt9mr3244442lab.15.1350726744801; Sat, 20 Oct 2012 02:52:24 -0700 (PDT) Received: by 10.112.83.100 with HTTP; Sat, 20 Oct 2012 02:52:24 -0700 (PDT) In-Reply-To: References: <9570D903A3BECE4092E924C2985CE485612C2595@MBX214.domain.local> Date: Sat, 20 Oct 2012 11:52:24 +0200 Message-ID: To: Jazzer Dane Cc: Amaury Bouchard , Clint Priest , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Accessors : read-only / write-only keywords From: nikita.ppv@gmail.com (Nikita Popov) On Sat, Oct 20, 2012 at 11:31 AM, Jazzer Dane wrote: > The final keyword is used, especially in sizable OOP applications. Claiming > it supposedly isn't used very often anymore - even if it were true - is not > an excuse to exclude the "read-only"-esque functionality in this RFC. Firstly, I didn't make that claim out of thin air, I actually checked how many final methods are used in ZF and Symfony (which are my usual reference projects due to their large size) and from that concluded that "nearly never" is a very accurate description. It could obviously be that those two projects are somehow special and everyone else uses large amounts of final methods ;) Secondly, low anticipated use is actually a very good reason to exclude functionality. One shouldn't add features from which you know right from the start that nearly no-one will use them. Thirdly, I don't want to exclude the possibility of enforcing read-only-ness through the hierarchy. I just don't want to provide a dedicated syntax for such an edge case. As already mentioned, there already are sufficiently simple ways to do this: // read-only for all classes in the hierarchy, only the current one can read final private set(); // absolutely read-only final private set() { throw new ReadonlyPropertyException; } The latter is even rather clear about the intention ;) > My top choice is final get;, which would work quite well and non-ambiguously > if we don't implement Nikita's proposed automatic accessor functions or > implement it in a noticeably different syntax. Not sure where you got that, but automatic accessor implementations are not my idea, they were part of the original proposal. I wanted to remove them, but later we found that they are necessary for various aspects of the RFC, in particular asymmetric accessor visibility (public $foo { get; protected set; }). Unless you want to drop that too automatic implementations have to stay. Nikita