Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92118 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88909 invoked from network); 7 Apr 2016 13:11:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2016 13:11:34 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:45098] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/88-48788-38C56075 for ; Thu, 07 Apr 2016 09:11:32 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 643182984212 for ; Tue, 5 Apr 2016 21:09:27 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5OXiVbPbzslB for ; Tue, 5 Apr 2016 21:09:21 +0200 (CEST) Received: from mail-lb0-f178.google.com (unknown [209.85.217.178]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id A3A08298420E for ; Tue, 5 Apr 2016 21:09:21 +0200 (CEST) Received: by mail-lb0-f178.google.com with SMTP id vo2so15717003lbb.1 for ; Tue, 05 Apr 2016 12:09:21 -0700 (PDT) X-Gm-Message-State: AD7BkJLJqSkvj8a6gVaUeFXDB8Lwa/NJ87qWUBmp6gra5noWVYb6K9NDQn0uiZeK1PyEpfFwkFhC0+Ns1NQfgQ== MIME-Version: 1.0 X-Received: by 10.112.53.100 with SMTP id a4mr164232lbp.116.1459883361159; Tue, 05 Apr 2016 12:09:21 -0700 (PDT) Received: by 10.25.24.40 with HTTP; Tue, 5 Apr 2016 12:09:20 -0700 (PDT) In-Reply-To: <008401d18f66$20e88300$62b98900$@tutteli.ch> References: <008401d18f66$20e88300$62b98900$@tutteli.ch> Date: Tue, 5 Apr 2016 21:09:20 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Robert Stoll Cc: Marco Pivetta , PHP Internals List Content-Type: multipart/alternative; boundary=001a11c3bc5a27d257052fc1951f Subject: Re: [PHP-DEV] Final properties From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --001a11c3bc5a27d257052fc1951f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Robert, Marco and Chris, now I see your point. Lastly I've found in DZone newsletter about Java putting `var` and `val` keywords, interesting is the second which is going to be used in case of immutable "variables" like a "values" (that's where `val` came from) see here http://openjdk.java.net/jeps/286 at "Syntax Choices" section. Checked C# for such feature and found out that there is something like `sealed` keyword which prevents from changing reference and also `readonly` keyword which states for property read only everywhere except class constructor (interesting isn't it?). I also read about "Immutable modifier" discussion and IMHO it looks like it's about time to get such feature. I also agree that `final` keyword may be not so good choice for immutability, I've checked Scala, Kotlin and Swift about final properties and it looks like there it is used to unable to override property accedentally, and putting additional `override` (see https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swif= t_Programming_Language/Inheritance.html) section "Overriding" says: "To override a characteristic that would otherwise be inherited, you prefix your overriding definition with the `override` keyword. Doing so clarifies that you intend to provide an override and have not provided a matching definition by mistake. Overriding by accident can cause unexpected behavior, and any overrides without the override keyword are diagnosed as an error when your code is compiled." Considerring all of that thoughts I think that `final` keyword in properties declaration whould be awesome with Typed Properties https://wiki.php.net/rfc/typed-properties keeping to not override the Type Hint declaration. I'll try my best to continue implementation of somehow immutable variables as they would be great at ValueObjects impl. The choice for proprietary keyword could be a subject of discuccion. Cheers, -- Micha=C5=82 2016-04-05 20:08 GMT+02:00 Robert Stoll : > Hi Marco, > > > > I am aware of what `final` means in other languages, it just seems that > everyone then needs to translate back and forth > > from `final` to `immutable`. In addition to that, `final` has different > meaning in inheritance (re-used keyword), so this adds > > to the confusion for people unfamiliar with the feature. > > I think immutable is also not ideal because to me, it sounds like the > whole object is immutable even though only the property is. I do not know= a > better solution than final though > > Cheers, > Robert > > > --001a11c3bc5a27d257052fc1951f--