Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101056 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63490 invoked from network); 4 Nov 2017 22:45:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2017 22:45:10 -0000 X-Host-Fingerprint: 95.148.70.12 unknown Received: from [95.148.70.12] ([95.148.70.12:18575] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/82-09857-6F24EF95 for ; Sat, 04 Nov 2017 17:45:10 -0500 Message-ID: <49.82.09857.6F24EF95@pb1.pair.com> To: internals@lists.php.net References: <14.52.09857.F0B0BF95@pb1.pair.com> <11.08.09857.30DFBF95@pb1.pair.com> Date: Sat, 4 Nov 2017 22:45:05 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: <11.08.09857.30DFBF95@pb1.pair.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 95.148.70.12 Subject: Re: [PHP-DEV] RFC - Array Of for PHP 7 From: ajf@ajf.me (Andrea Faulds) Hi Mark, Mark Randall wrote: > On 03/11/2017 02:27, Andrea Faulds wrote: >> Your proposed objects would not be usable everywhere an array is, >> because they're not arrays, and by converting to an array you lose the >> type info, so we still have to iterate over the whole thing to type >> check. This would be significantly less useful than an actually typed >> array. I can see some benefit to it, but I'm not sure it's worth the >> effort. > > Thanks for the reply. > > So if I am following right, would your goal in the short-to-mid term at > least be to attach type information inside the HashTable, or as part of > the zval value? Inside the HashTable, yes. There's no space to hide it in the zval, and it's not the zval it's specific to anyway. > > I may be pulling this out our my arse of course, but does the nature of > an array not mean that the individual values inside can be used as > references and potentially break the type restrictions and require > all-item checking again? > > $t1 = array([ 'hello', 'goodbye']); > $val = &$t1[1]; > $val = 1; > -> [ 'hello', 1] Yes. There's a similar problem for implementing typed property. I think Bob Weinand might have been working on a solution to this (typed references), but I have no idea where that went, if anywhere. Thanks. -- Andrea Faulds https://ajf.me/