Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79260 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98459 invoked from network); 28 Nov 2014 06:46:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Nov 2014 06:46:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.46 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.46 mail-pa0-f46.google.com Received: from [209.85.220.46] ([209.85.220.46:35149] helo=mail-pa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/B5-59154-83A18745 for ; Fri, 28 Nov 2014 01:46:17 -0500 Received: by mail-pa0-f46.google.com with SMTP id lj1so6216573pab.19 for ; Thu, 27 Nov 2014 22:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=EtgNvtNz5VksJKIUn8VvSnrbJKUEcB522yv7E0GjXyI=; b=whqBhtobgOi66h89JUu0VAvO0TRQuHtEjaRZsNSqyVCGI5BG84KuZs0WVA4Nsypm4M hrWA5ziikkX+gUpW4Yoolela7AKHbLE93oTssbVjBIPVlJcu8otyS/71gwonjWlidscz nKhzyea57mBAOQ+H0ZoZptiyiQ+gYv4zb4+awWWSPi7L96CeYOJEkaa9cilgjOvMyla7 fKSdbc8cFiIuie9O8fYqqUGkr0heLGq55rm6j9P1v4pjLriJtPnUeNayJdg+92UVHZh+ 7DiMHx8R51mS4cYUTThTHbjVNdqSDkYNOUyAybE2tVwQ996QcTqucCVdvPYyjPlY0DZW pDxw== X-Received: by 10.68.132.198 with SMTP id ow6mr69998312pbb.61.1417157173665; Thu, 27 Nov 2014 22:46:13 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id qf1sm8880279pdb.49.2014.11.27.22.46.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Nov 2014 22:46:12 -0800 (PST) Message-ID: <54781A33.4010103@gmail.com> Date: Thu, 27 Nov 2014 22:46:11 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Marc Bennewitz , PHP internals References: <5474F3FA.8050108@mabe.berlin> In-Reply-To: <5474F3FA.8050108@mabe.berlin> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Idea: immutable class / object From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Because of for immutable objects it's not allowed to set an mutable > object as property > you can be sure the object's state will be consistent. That's the main It may be harder to achieve than you think. How exactly do you ensure they property values do not end up containing mutable values? I.e. something like this in the ctor: $a =& $this->foo; $a = bar(); How do you ensure $this->foo does not have mutable value in it now? Also, would that mean that you can not call any function that accepts values by-ref with anything derived from $this? It may be not easy to do. Also, I'm not sure how practical it is. I.e., immutability is very imporant in some applications like parallel processing and also for some languages where some performance optimizations rely very hard on certain constructs being immutable, but in PHP there are no such things, so except for documentation, what would be the added value here? -- Stas Malyshev smalyshev@gmail.com