Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91848 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11584 invoked from network); 22 Mar 2016 15:04:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Mar 2016 15:04:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=bjorn.x.larsson@telia.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=bjorn.x.larsson@telia.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain telia.com from 81.236.60.154 cause and error) X-PHP-List-Original-Sender: bjorn.x.larsson@telia.com X-Host-Fingerprint: 81.236.60.154 v-smtpout1.han.skanova.net Received: from [81.236.60.154] ([81.236.60.154:43553] helo=v-smtpout1.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/58-46740-7FE51F65 for ; Tue, 22 Mar 2016 10:04:26 -0500 Received: from [192.168.7.7] ([195.198.188.252]) by cmsmtp with SMTP id iNr2aBH48TjSziNr2acYRa; Tue, 22 Mar 2016 16:04:21 +0100 To: Rowan Collins References: <1458149992.3969.2.camel@kuechenschabe> <1458151531.3969.8.camel@kuechenschabe> <1458153695.3969.16.camel@kuechenschabe> <3F.70.02405.6803BE65@pb1.pair.com> <56F01545.8080008@gmail.com> <56F14572.701@gmail.com> Cc: PHP internals Message-ID: <56F15EF5.80006@telia.com> Date: Tue, 22 Mar 2016 16:04:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <56F14572.701@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfBeLEk4lNqRQ4jJ0NHYEFUfp34by5u1Jdo2oRfLa3Lsz0OgolYv5m4c1hVjiNcuNbSGv02gVl6Cbp8LfHJaFhwBZhKBEKjrC0VoeNOyTftsSdvwJ0RCb R1iIN5T3APseONVRMvk8e1XZGJ18g+GAEoyRe7tjfBV0dXe8J2Y9mgNtri98cJ6q3e92wezi4oxwoOqijiT6b2kLSOqcWkE0IkjMG1YlrM3jA9ah0K4fqICi Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2016-03-22 kl. 14:15, skrev Rowan Collins: > Nikita Popov wrote on 21/03/2016 17:05: >> While it is no secret that we don't particularly like references, >> this is not the reason why they are forbidden. There is no conspiracy >> to punish users of references by denying them use of new typing >> features. No, the reasons here are technical. Let me illustrate some >> of the issues involved in more detail. > > > Thanks for the detailed explanation of the problems, which are indeed > deeper than I'd appreciated. To be clear, I never thought it was the > intention to dissuade users from using references, but a couple of > people have implied that they consider it no bad thing. > > > For me, the restriction on setting references makes this whole feature > a no-go for the language as it stands. I don't think it is at all > reasonable for the following code to produce a TypeError: > > class Sorter { > private array $data; > public function __construct(array $data) { > $this->data = $data; > sort($this->data); > } > } > new Sorter([1,3,6,5,2,4]); > > > It may be that we've reached the limit of how much typing we can add > to the language incrementally, and need actual typed variables, so > that references could be made only between variables with the same > type hint, e.g. > > class A { public int $foo=42; } > $a = new A; > int $ref =& $a->foo; > > The sort() example would work in this scenario because the expected > parameter type is array, so the reference being created is of the > matching type. > > Obviously, this would be a huge change to the language, and no doubt > have all sorts of impacts and problems of its own, but I don't think > it makes sense to say "you can typehint your property names, but you > lose some existing functionality if you do so, for technical reasons". > > Regards, Hm... In Hack the above code works, see: https://3v4l.org/nsA5W Well they have a different implementation as mentioned in the RFC, so no wonder. But they do have typed porperties in the language. Regards //Björn Larsson