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?

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]

I did take a look in zend_types.h half expecting to see a pointer to an optional structure defining an indirect function call + argument to be called whenever the zval_value was about to be changed, but if it's in there, I missed it.

--
Mark Randall

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

Reply via email to