Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89254 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49761 invoked from network); 17 Nov 2015 01:54:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2015 01:54:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wm0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:33210] helo=mail-wm0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/C6-34372-2C88A465 for ; Mon, 16 Nov 2015 20:54:11 -0500 Received: by wmec201 with SMTP id c201so205136498wme.0 for ; Mon, 16 Nov 2015 17:54:07 -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=FxKYkAkXgc+qfdBe9J81V8N0x6AZScSbYt7nXEwjS88=; b=rwWTCTEcbUO3n3f2CZnRQKuPfbzYGb8wTAZ3qmNsOHsdjprWKQ2xpy1o1PKdLMVIYG 3Uce58l6+mLwvrJePDofdKQ8ZnJpQSY2otsZR8u5ULXK7aVPQIknuAAM51hkBh7j49XU Qzr68MWSARh27NwgPRaBwBRP02kBGLYgmLizBKT51k9SVloY9sKe1OJ/JYrfqwY8dyIP zcBsvKoA23HAg84Xc8QDw21+vVvzZjq+ozjG8mVyz2Cm07WWfIk7k7ZHO7ym1/mSBsCf TLmQCQcW9a+gxpphBZ4jSHwU2UnPHBt4a3dovI8ubREZND90BYmZTryjaIrAmZ5Zu14v rx3Q== MIME-Version: 1.0 X-Received: by 10.28.218.72 with SMTP id r69mr23171131wmg.98.1447725247234; Mon, 16 Nov 2015 17:54:07 -0800 (PST) Received: by 10.28.226.10 with HTTP; Mon, 16 Nov 2015 17:54:07 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Nov 2015 20:54:07 -0500 Message-ID: To: Chris Riley Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Immutable modifier From: ircmaxell@gmail.com (Anthony Ferrara) Chris, On Mon, Nov 16, 2015 at 4: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. Beyond syntax/whatever, I would suggest finding a method to do it internally. That's going to be the biggest problem in my experience (finding some way of doing it efficiently)... Anthony