Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89249 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35230 invoked from network); 16 Nov 2015 23:40:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2015 23:40:02 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.41 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.41 mail-vk0-f41.google.com Received: from [209.85.213.41] ([209.85.213.41:35802] helo=mail-vk0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/54-34372-0596A465 for ; Mon, 16 Nov 2015 18:40:01 -0500 Received: by vkas68 with SMTP id s68so1918499vka.2 for ; Mon, 16 Nov 2015 15:39:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=NGKjzEA1o7JpwHc3+hPyimwNoYVzZARcFmsAhtBvmcw=; b=d/hrjt1o063s5ctKQEmEEDmOgoQVH/6aqnkw52ebU/YhcKtevI1Y800or57Lvm9IDC wKwZgNW9aMqh4NjD3v0GfzfX50emYrKMzOTJLFgIKywZ4arp6M1gqgj/g3XCLcTyWel3 hEAWaR0v7WtP0Lr5ELYD/atM8ar4oC+4E8kfAB7I+q72fHBP4tIwJKJkf/mJXxgTVZYr uc1iaTcGoeaZH17vwE+zIUo2oGGwjyMpHsm9+L+n0U6kZBdiPrCdhH7PlzUPqI6zk/GK vP/ZCh/KTL6i39OCSQPFP/kxZS+4WwMYvC7YYe3P6A6D12cnN6ElP72gzedgpM6YPYGR Ghug== MIME-Version: 1.0 X-Received: by 10.31.149.141 with SMTP id x135mr590027vkd.40.1447717197797; Mon, 16 Nov 2015 15:39:57 -0800 (PST) Sender: morrison.levi@gmail.com Received: by 10.31.191.75 with HTTP; Mon, 16 Nov 2015 15:39:57 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Nov 2015 16:39:57 -0700 X-Google-Sender-Auth: KvVAIadI7qY-p-wYglz-5OFG6XY Message-ID: To: Chris Riley Cc: PHP internals Content-Type: multipart/alternative; boundary=001a114268dc4f61400524b0ed83 Subject: Re: [PHP-DEV] Immutable modifier From: levim@php.net (Levi Morrison) --001a114268dc4f61400524b0ed83 Content-Type: text/plain; charset=UTF-8 On Mon, Nov 16, 2015 at 2: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 > In my opinion we should just generalize const for this, rather than add a new keyword. --001a114268dc4f61400524b0ed83--