Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63551 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13883 invoked from network); 20 Oct 2012 09:05:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Oct 2012 09:05:06 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; 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:58436] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/3B-22055-04962805 for ; Sat, 20 Oct 2012 05:05:05 -0400 Received: by mail-la0-f42.google.com with SMTP id e6so782478lah.29 for ; Sat, 20 Oct 2012 02:05:00 -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=oO4nXMGglFmPy7MZCv1/2RfRKrWKqs5mfZCDCtlISWQ=; b=d4rhO6UU7Llv1OoeM/1E3m/IhKozRJuwEX4cy/n1StdNwcho5a/CGqxbfv06SVRGA2 Bx1e1jQhsQuLrA6kZK1maD+rGuXnGIvT3B5khv9y/wIxTxn8NtxqE27gJnCo2PMwZgxC tAVqSX6e1sm+XxNqNd/dljBdLVAcCajLsON9kfrB5zB5c+mofh3WpGTK5KOAKLEQcXwp NewBzBfqYmIa3oCJ1sdCOvnKbgwJZHRVjK8cB7HtGAU7AVe5O+iWFe3JXpe86wCT/tfc cm/byFQTAWrd03OiP99LhuhwgDtZWNhSDufVgv48PTMOlCSt2ktV7Oq2JRWKo8PshodF TLlQ== MIME-Version: 1.0 Received: by 10.152.108.37 with SMTP id hh5mr3114696lab.52.1350723900634; Sat, 20 Oct 2012 02:05:00 -0700 (PDT) Received: by 10.112.83.100 with HTTP; Sat, 20 Oct 2012 02:05:00 -0700 (PDT) In-Reply-To: References: <9570D903A3BECE4092E924C2985CE485612C2595@MBX214.domain.local> Date: Sat, 20 Oct 2012 11:05:00 +0200 Message-ID: To: Amaury Bouchard Cc: 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 9:29 AM, Amaury Bouchard wrote: > read-only => final set null; > It begins to be verbose. > > As I said many times, why don't you want to use the "const" keyword? It > already exists and is pretty well understood by everybody. Could you maybe explain where exactly "const" would be used? Please don't forget that we do not use your "foo:bar" syntax, so where would the "const" go with the currently used syntax? Anyway, I'd like to give a quick comment on read-only: I mainly don't like the keyword because it doesn't do what I expect it to do. When I first glanced over the RFC I thought that read-only was a way to define read-only properties (i.e. properties that can only be set via default value or in the constructor) along the lines of "public read-only $name = 'FooBar';". This is what the "readonly" modifier means in C# (which is the language the RFC is adopted from mainly). In C# readonly can *not* be added to properties with accessors, only to simple fields. With the current RFC / the original proposal "read-only" gets a completely different meaning. I think that the behavior of the modifier in C# is useful, whereas its behavior in the original accessors proposal is mostly pointless. I mean, why would you need to strictly enforce that a property is read-only throughout the inheritance hierarchy? From an interfacing (LSP) point of view it's not of importance whether an additional set accessor is added, as long as the get accessor stays. I would guess that "read-only" will be used about as much as "final" is used today. And "final" is nearly never used. That's why I really don't think that we need any kind of special syntax for this. If you do happen to be the rare case where you need to enforce the read-only-ness throughout the hierarchy, you can always use the "final private set()" approach (maybe even throwing an exception from it so you can't even access it from within the class). Everything else seems unnecessary to me and would only make things more complicated than necessary. Nikita