Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89226 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48217 invoked from network); 16 Nov 2015 09:33:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2015 09:33:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=fontanalorenz@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=fontanalorenz@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: fontanalorenz@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:33055] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/10-46953-2F2A9465 for ; Mon, 16 Nov 2015 04:33:39 -0500 Received: by wmec201 with SMTP id c201so166243596wme.0 for ; Mon, 16 Nov 2015 01:33:35 -0800 (PST) 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=2ndS4tCeSQm0L2GLk9EX0OkQ3SHl7gnnU3RbC0xgA2o=; b=AypqZpWzy0ixpahZGLOJnaPSE3jwWJTUwcMO+pvI8ZuKe6qCq3QgBcNc3+ZUY6dCHy jKlTpnnEpK3S2Nc1MSnyYa9IUylyZ6ZAE99iGFABBeIyoTUQNvtLu0AqKMGYAoPFO3pX nPZWkcsZtsFV16qTRQi1ZYoDllXWQvzT3O6tZPoMBrxvKyUCh45YtD566+67u/yBdlto X/PZATgap4f5C64Xfww/Ge47pis3SoeEP9Z1dYwIqulsR/ukJ0cMD6gVTk0jPZ6NtgU+ Hdg2SgjV8qxaoiAlE5vJmzRG/DRwajCX5Vmm+lLInWigawlBZrQWGwcJ/Jncw7zAsjmm +8BQ== MIME-Version: 1.0 X-Received: by 10.28.131.84 with SMTP id f81mr16731128wmd.57.1447666415649; Mon, 16 Nov 2015 01:33:35 -0800 (PST) Received: by 10.28.64.138 with HTTP; Mon, 16 Nov 2015 01:33:35 -0800 (PST) Received: by 10.28.64.138 with HTTP; Mon, 16 Nov 2015 01:33:35 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Nov 2015 10:33:35 +0100 Message-ID: To: Daniel Persson Cc: internals@lists.php.net, Chris Riley Content-Type: multipart/alternative; boundary=001a11443d1c7549ef0524a51af7 Subject: Re: [PHP-DEV] Immutable modifier From: fontanalorenz@gmail.com (Lorenzo Fontana) --001a11443d1c7549ef0524a51af7 Content-Type: text/plain; charset=UTF-8 I really like the concept of immutability, but I think that it should be applicable at instance level rather than declaration. I would also prefer another keyword than immutable. Final does not make the properties immutable, it makes the class not extensible. On Nov 16, 2015 10:24, "Daniel Persson" wrote: > Any differance from the final keyword? > > http://php.net/manual/en/language.oop5.final.php > > On Mon, Nov 16, 2015 at 10:15 AM, Chris Riley wrote: > > > Hi, > > > > There has been a lot of interest recently (eg psr-7) in immutable data. > I'm > > considering putting an RFC together to add language support for > immutables: > > > > immutable class Foo { > > public $bar; > > public function __construct($bar) { > > $this->bar = $bar; > > } > > } > > > > Immutable on a class declaration makes all (maybe only public?) > properties > > of the class immutable after construct; assigning to a property would > > result in a Fatal error. > > > > class Foo { > > public $bar; > > immutable public $baz; > > } > > > > Immutable on a property makes the property immutable once it takes on a > > none null value. Attempts to modify the property after this results in a > > fatal error. > > > > Any thoughts? > > ~C > > > --001a11443d1c7549ef0524a51af7--