Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67583 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33923 invoked from network); 28 May 2013 09:50:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 May 2013 09:50:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.173 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.223.173 mail-ie0-f173.google.com Received: from [209.85.223.173] ([209.85.223.173:35954] helo=mail-ie0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/5E-44058-2ED74A15 for ; Tue, 28 May 2013 05:50:26 -0400 Received: by mail-ie0-f173.google.com with SMTP id k13so1059323iea.32 for ; Tue, 28 May 2013 02:50:23 -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=NFH15tQknBvjKWvvzB7iIK6WO1QeuI+KqW+WMZyTQug=; b=LUIKVDiGa95o1vYuPoHzYNGa9ybciRLX4Q92r6o8vVGBRyUEki+7XEspxu76XzSmqK zTLPtjK0NNRSu2LD8i7bEgUSSx50pwuwg2Oy2VmUccwxtZkQaJElq++v06AVfuGXpdiU bACPFJG8fCF4KgR87rYVsxfwECFj1Wv1VcfbdGG/YsG3e5rpUkqnJOtTY0Q9LhP7WmkY Q6c4F3MdVEIEjfuERiuHxClsRI47iF6JzZ5wyul84csvAHVljOrWEFiremT7QWoAHIld ur04QVVoExds2Gu9gjahJtauN1S7K4Il6ViaNbcVGi6lnRXYIaaXDwjvqwhCq77j/Wzs h1Iw== MIME-Version: 1.0 X-Received: by 10.50.44.77 with SMTP id c13mr6522183igm.17.1369734623648; Tue, 28 May 2013 02:50:23 -0700 (PDT) Received: by 10.50.209.3 with HTTP; Tue, 28 May 2013 02:50:23 -0700 (PDT) In-Reply-To: <06F1F2BA-A054-4B62-AD06-90B621995ADD@strojny.net> References: <06F1F2BA-A054-4B62-AD06-90B621995ADD@strojny.net> Date: Tue, 28 May 2013 11:50:23 +0200 Message-ID: To: Lars Strojny Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7bdc1874ade4ae04ddc431b2 Subject: Re: [PHP-DEV] supporting the final keyword for properties From: tyra3l@gmail.com (Ferenc Kovacs) --047d7bdc1874ade4ae04ddc431b2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, May 28, 2013 at 10:58 AM, Lars Strojny wrote: > Hi Ferenc, > > Am 28.05.2013 um 08:15 schrieb Ferenc Kovacs : > [...] > >> 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 o= n, > >> 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? > [...] > > the accessors rfc got rejected, so I'm bringing this up again. > > It=E2=80=99s a good idea in general but what about having it for variable= s as > well? Could open interesting possibilities for an optimizer. > > final $foo =3D "str"; > $foo =3D "bar"; // bails out > > cu, > Lars I think that this proposal only makes sense in a class context. For your example we already have a solution: constants. Unfortunately class constants has more limitation, as you can't assign expressions to them, and using global(namespaced) constants which will be only used in that class breaks the encapsulation part of OOP, as your constants are "leaking" out. One solution would be to allow the class consts to accept expressions, but for that the simple solution would slow down the class constanst for everybody. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --047d7bdc1874ade4ae04ddc431b2--