Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81742 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71328 invoked from network); 3 Feb 2015 21:58:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2015 21:58:44 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.169 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.169 mail-we0-f169.google.com Received: from [74.125.82.169] ([74.125.82.169:54601] helo=mail-we0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/3A-20608-29441D45 for ; Tue, 03 Feb 2015 16:58:43 -0500 Received: by mail-we0-f169.google.com with SMTP id u56so47563006wes.0 for ; Tue, 03 Feb 2015 13:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to:cc :message-id; bh=qZFrEm2T7GPpQ1HKMRAjeVJvlTe/+gMdsHy9n2OqdeM=; b=rZXmGgZtzixJxvum6pNBpVlx/B5KAKRb2SoRgjGFGHzohW6ts/wvl096pQYTQ+e0mb Wwo/3nS7qWW4HGaFLwMMMQ1aabvLTJt9KMBgQFsGNmfkbmf2WGVXWwoSuNDQ1wBonPef zG2Hf7jdYlIw7qZkz5YNGQU+nCzqMueIFG8XmXA4EmMdqgvToGleM6ygY1mTYY59MLS1 D9/Dc3cys7fq52AKOfSG1MFNqlRe33+BjGWZ7E688NGbvXPjJ/02Pgv36F8Cq03R8Vzq jWbOsBJctMhL9lwhZWsErNmDtzLVTZz4278XyipP/u6+cMeKCUFWikdvcXMxU0Y0Q7MT BFyw== X-Received: by 10.194.81.161 with SMTP id b1mr60136017wjy.2.1423000719367; Tue, 03 Feb 2015 13:58:39 -0800 (PST) Received: from [100.116.53.143] ([213.205.194.219]) by mx.google.com with ESMTPSA id pp10sm11074679wjc.31.2015.02.03.13.58.38 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 13:58:38 -0800 (PST) User-Agent: K-9 Mail for Android In-Reply-To: References: <54CBC804.7050706@gmail.com> <54CD7668.30301@garfieldtech.com> <61B0AAF8-9A3E-4889-917E-42AA48D946FA@ajf.me> <54CF4126.8030901@lsces.co.uk> <54CF4B14.4080806@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Tue, 03 Feb 2015 21:58:35 +0000 To: Alexander Lisachenko CC: PHP internals list Message-ID: <033FF208-3BCA-4C73-B5B5-95DA32956B5A@gmail.com> Subject: Re: [PHP-DEV] [RFC] Immutable variables and objects From: rowan.collins@gmail.com (Rowan Collins) On 3 February 2015 06:59:06 GMT, Alexander Lisachenko wrote: >I want to add a link here to the Java article about Value Types, this >information is quite interesting: >http://cr.openjdk.java.net/~jrose/values/values-0.html > >Probably, immutable value objects will be soon in Java world according >to >this information: > > >> Conclusion >> >> Along with the questions, we believe we have enough answers and >insights >> to begin prototyping value types, and verifying our thesis. That is, >we >> think it quite likely that a restricted class-like type can be made >to look >> enough like a primitive to be worth adding to the language and VM. Ooh, that does look like an interesting read. I'm particularly intrigued by their notion of "custom basic types". I'm beginning to dream about such types being a way of introducing various features: - immutability and/or COW; if they can't have normal objects as members, then the deep cloning/immutability problem basically goes away - operator overloading (without allowing it on normal objects); perhaps further limited to cases where both operands are of the same type (e.g. money + money) to avoid complicated dispatch algorithms - range and domain types as sub-classes of scalars, with some kind of cast declaration; dare I say it, this could be more useful than scalar type hinting, since you're able to check arbitrary limits - "scalar methods" / autoboxing; standard PHP could include basic methods (e.g. those array_* and str_* functions which have a natural "subject"), and you could add more by casting to a subtype, with much less overhead than an object wrapper Maybe if we keep experimenting, we can come up with something really awesome for PHP 8... -- Rowan Collins [IMSoP]