Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61295 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88265 invoked from network); 16 Jul 2012 13:35:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 13:35:45 -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.214.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bk0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:49891] helo=mail-bk0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/42-11081-0B814005 for ; Mon, 16 Jul 2012 09:35:44 -0400 Received: by bkcjm19 with SMTP id jm19so4233316bkc.29 for ; Mon, 16 Jul 2012 06:35:41 -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=0iezZQI58HP/8EW5PjzbVJmSBWG9gGJHUUSVoWWaMDw=; b=xE0uX5g3PEslFsRyaU9SXM4DzUGHlmwevJUioI9W0ceBl1b9a2lBJ0+oV/7ZtnJOPW 4sApC2CstLscjY70fMsuwAX7BYf4xdEF/5cdfKS6LmJjM3oVcuuEw4M7m5J5gv8GoAFy +sp4rXBIOACcrJUBF3VdiRIuwBBobTtYNSzkJgNJtzDtceaujLKSa9OTBIbUs3FZtHg1 YZ4IKYdMrryNdhql+k/ywSlwZ4vfMsLUHA/EP6kvgxTtMRth3ye4BRsEDo/9WpGHYNqZ OytPNy1k3VqL5Xj9QqHnSZnUJQcKG600zRiBDvUEr+B+JICnYXq4dXAASVUzWWmD3A6w RW8g== MIME-Version: 1.0 Received: by 10.152.132.40 with SMTP id or8mr11558612lab.24.1342445741282; Mon, 16 Jul 2012 06:35:41 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Mon, 16 Jul 2012 06:35:41 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 Jul 2012 15:35:41 +0200 Message-ID: To: Ferenc Kovacs Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] supporting the final keyword for properties From: nikita.ppv@gmail.com (Nikita Popov) On Mon, Jul 16, 2012 at 2:25 PM, Ferenc Kovacs wrote: > Hi, > > The recent http://www.mail-archive.com/internals@lists.php.net/msg59301.html > discussion > made me wonder why did we decide not supporting the final keywords for > properties as it would provide an easy way for read-only attributes (const > would be a better choice in performance wise, but then you can only set it > in your declaration where no dynamic expression is allowed.) > > I would like it to work the same way as it does in java( > http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.4) eg. > you can set the initial value either in the declaration or later on, but > after it is set, you can't change it, trying to do that would create a > recoverable fatal error (or throwing an exception which extends > RuntimeException). > > What do you think? Would this be viable? Is there any still-present reason > why we shouldn't support that? I don't like this overloaded meaning of "final". "final" currently means "cannot be overwritten by inheritance". This would add a second meaning which would be somewhat similar to "const" (but only somewhat). Nikita