Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33161 invoked from network); 5 Apr 2016 09:13:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2016 09:13:51 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.178 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.217.178 mail-lb0-f178.google.com Received: from [209.85.217.178] ([209.85.217.178:36206] helo=mail-lb0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/11-27948-DC183075 for ; Tue, 05 Apr 2016 05:13:49 -0400 Received: by mail-lb0-f178.google.com with SMTP id qe11so5139997lbc.3 for ; Tue, 05 Apr 2016 02:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pUPco+V2xWbuZA1FhJeoCdx+eVh5EuGx2HJ1NzwrtdQ=; b=Lco77xtSQkHTMe2OdvKMVXn8pecUL/GqVvmt3DOelmLDBrEiG+zXEV00dL8cGT6gNl xzx7C6wGLDhCAj2fjTBouWy8wuH1NY5Z6oFFLgh/a9YFYv/E3xtniK2wxXF1kXaMwNFp ZvAyFPyJTDyyaBD+VlFwfJmm/BcVC/T0lpObheIzREYQq1t//13QApi+DSRRTMd9cWW7 yfJtUnu/7uArUFrkO6P2HoxRDsJ9wMXtgmoxN6QKA6Y5FnH6yJK7AWTHJtitSGk1LpMy pVStOwqWl3XCVJOzkCKOFULBvT9d+6/YFlV3UddG1nnqXARdbY3oHUvZv51oo0HABm6g Uiow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pUPco+V2xWbuZA1FhJeoCdx+eVh5EuGx2HJ1NzwrtdQ=; b=M0/4VjGfnLrD34wi5+QQfyzk/6poVorkgAI8y3qJ9Xm63yCsQBkNFYgLw1pazTJQaH iUbtrDtF5sfCDGoZTf5RzbFoEwQ2lEgYkgCfXTIJYFjwm3bkRc/dpw2y/AC+Z3VZl49y K1QJp3PrnAUVMs++c9Fe6cgEKoqfC/dB72lrPoxsQGpvdvDteGYLA6cMFQnLVJqGgvLF ftYbjDQdJUZSe/1zRpiO88wOFx4sGJ1X3O4XqgFt4bMEYMV3fi9kUKoR8+0SGwC1uzzo 70akimWqDwjfpnjLV3ducGLdItGa4W/8XrBFk81hJvJ1AddT6yBUFxYp+aprkR2TG+JT hmxw== X-Gm-Message-State: AD7BkJJdcqnS521V9yNBVtyP+2nFeZ6dMYO+eZbd1e8FUNQSuNKd4BICLiVDEtHqtNnHpbY/r9smKyvcuwZx3A== X-Received: by 10.112.198.65 with SMTP id ja1mr3775498lbc.123.1459847626496; Tue, 05 Apr 2016 02:13:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.126.67 with HTTP; Tue, 5 Apr 2016 02:13:26 -0700 (PDT) In-Reply-To: References: Date: Tue, 5 Apr 2016 11:13:26 +0200 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Brzuchalski?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a11c3409a342299052fb94368 Subject: Re: [PHP-DEV] Final properties From: ocramius@gmail.com (Marco Pivetta) --001a11c3409a342299052fb94368 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Micha=C5=82, First of all: +1 to this: very useful for value objects! A few questions: * can you re-declare a final property in a sub-class, making it therefore non-final? (I have reasons to do that, related with altering states via mappers) * do we want to use `final`, or `immutable` for these properties? `final` seems to just be a confusing term here. * is this feature portable to variables in general? I realize that adding metadata to ZVals has huge performance implications, but it would be interesting to do that for performance improvements further down the line Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 4 April 2016 at 19:53, Micha=C5=82 Brzuchalski = wrote: > Hey Internals, > > I'm new here. I've been wondering / working on adding final properties in= to > PHP lang. > > This work started once I had the time to read the "Core Java for > Impateient" by Cay S. Horstmann > and found it very usefull to have final properties like Java. > > Those properties differ than `const` because they can be set at runtime - > but only once in their lifetime. > Such properties could be very usefull in Singletons, ValueObjects etc. im= pl > like: > > class Money { > public final $amount; > public final $currency; > public function __constructor($amount, $currency) { > $this->amount =3D $amount; > $this->currency =3D $currency; > } > } > > In above example there is even no need for getter because those propertie= s > are immutable through > the final keyword, it means those properties cannot change their referenc= es > just like in Java > https://en.wikipedia.org/wiki/Final_(Java) > > I've already started some impl on own fork > https://github.com/php/php-src/compare/master...brzuchal:final-properties > I've got some basics in C programming, don't know yet if I can impl it > complex. > > I was wondering if it is usefull in yours opinion or is it only my > impression. > > I can provide an RFC if it sounds usefull and if I get Wiki karma > > Thanks > -- > Micha=C5=82 Brzuchalski (aka brzuchal) > --001a11c3409a342299052fb94368--