Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92187 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74484 invoked from network); 11 Apr 2016 04:59:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2016 04:59:44 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.27 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.27 out3-smtp.messagingengine.com Received: from [66.111.4.27] ([66.111.4.27:42988] helo=out3-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/50-04135-E3F2B075 for ; Mon, 11 Apr 2016 00:59:43 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id DE6D1201FD for ; Mon, 11 Apr 2016 00:59:39 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Mon, 11 Apr 2016 00:59:39 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=bTCCOf+bbE1wO0k HdRdkj7CZ4YA=; b=RDvsA4G5XJ+mWgnZNaNl88TdaonGmLYO87yJXmNIzS7EOnM TqbTJy89D6h5DDcgddvnPYCO189YO/m7QCjjygBLwtBwE515V7NJ5Cv/i4I1alMz ZsZ62dfgcnaKtilr+5k8JPefnFOV3e6MiJQzw+hWcP2cQvoaM0T2S3ngDpbw= X-Sasl-enc: 9hq2vJn8i3fR6IJcPYXcQf6z0gn7lUT43YOlTI4bRQc7 1460350779 Received: from [192.168.42.5] (c-50-178-40-84.hsd1.il.comcast.net [50.178.40.84]) by mail.messagingengine.com (Postfix) with ESMTPA id 9914DC0001C for ; Mon, 11 Apr 2016 00:59:39 -0400 (EDT) To: internals@lists.php.net References: Message-ID: <570B2F3B.7040609@garfieldtech.com> Date: Sun, 10 Apr 2016 23:59:39 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Final properties From: larry@garfieldtech.com (Larry Garfield) On 04/05/2016 05:13 AM, Marco Pivetta wrote: >> Ad. 2. `final` means class variable (like static) or class instance >> property can not change their reference, it is impossible to replace zval >> in such property, in my opinion `immutable` is object behavior when using >> some methods you receive newly created (cloned) object which is changed >> exactly like `DateTimeImmutable` >> http://php.net/manual/en/datetimeimmutable.add.php >> > 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. There's an important point here that should not be missed. If these values are "write once then locked', which I can definitely see as useful, we need to have another shot at modifying them from __clone(). If not, they are effectively useless for implementing objects in the style of DateTimeImmutable or the PSR-7 Request/Response objects. Locking after __construct or __clone (as appropriate) is done is fine, but if we can't clone-and-modify then I would pretty much never find value in this feature (no pun intended). I agree that final seems like a potentially confusing keyword, as every other use of final (AFAIK) means "subclass cannot change this", but that's not at all the meaning here. Another question, which unfortunately runs straight into the previous Properties RFC: If a public property is write-once, with the intent being that it's set from the constructor and then cannot be overridden but is publicly exposed... shouldn't an interface be able to declare it as well? It makes public properties safe to use in some cases, but you can't rely on that safely without an interface. (Which leads to "can interfaces define properties", which leads right back to "well what can you do with them", which leads back to the Properties RFC. Which I still want to see happen at some point if at all possible, as it would also subsume this question quite nicely.) --Larry Garfield