Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61291 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79074 invoked from network); 16 Jul 2012 12:59:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 12:59:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.49 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.49 mail-qa0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:43550] helo=mail-qa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/60-11081-22014005 for ; Mon, 16 Jul 2012 08:59:15 -0400 Received: by qabj40 with SMTP id j40so1642401qab.8 for ; Mon, 16 Jul 2012 05:59:12 -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=xpvGs2z9BLmlN2dAhN/5+nSMpPBeQxrECZqRYTbdiQg=; b=g0QaOyKIM7iW7kEHfenuolZW5t1bnAjCpk6AjqC77QX0D8jqa63ikAjxNjMxZ1ZH2x orGtVcnDi/qjFUNoMsiRviynqcjwT3GthldE5vt8g901f6AOdBd7ZkQM24kS+OV+sxvP p80qhTXyA6gXUhx/PVFy1i60OYlIu/V/w+jIGsaYBM15NZkL45O4qO5hrV9sgyq5WdYI Ijd7gtY4m/iIcLGWNDzPTWl+LenXmtksmt/ZWvdWM2WAR+P2wmcxeCznW/urN6OzY129 QKCLlsvVF087IpQfLlTAN8Ur6yA8GKOUNt8xXk4myhQ8hPT2TIrxY6AqBH/e8wrtISxH ipQA== MIME-Version: 1.0 Received: by 10.224.105.193 with SMTP id u1mr6248964qao.85.1342443552393; Mon, 16 Jul 2012 05:59:12 -0700 (PDT) Received: by 10.229.182.4 with HTTP; Mon, 16 Jul 2012 05:59:12 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 Jul 2012 08:59:12 -0400 Message-ID: To: Ferenc Kovacs Cc: PHP Internals Content-Type: multipart/alternative; boundary=20cf306682a712480204c4f1ff1f Subject: Re: [PHP-DEV] supporting the final keyword for properties From: ircmaxell@gmail.com (Anthony Ferrara) --20cf306682a712480204c4f1ff1f Content-Type: text/plain; charset=ISO-8859-1 Ferenc, On Mon, Jul 16, 2012 at 8:25 AM, 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? > My question would be where in code would this be enforced? A trivial implementation could be done in the object.write_property handler. But wouldn't things like references and the such (read_property and get_property_ptr_ptr, as well as get_properties) also be paths to writability? Would that then mean that this would need to be added to the zval type directly, and not just the property table? And if that's the case, why not make it final for the entire engine (meaning that I can declare a global property as final using `final $var = 1;`)... Thereby making this a rather significant engine changes? Or is there an easier way that I'm missing...? Anthony --20cf306682a712480204c4f1ff1f--