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<string>([ '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/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to