Hi, Matthew Brown wrote:
I imagine such a "list" type would be a subtype of "array" – everywhere that array was accepted, a list would be also, and it would have the same copy-on-write behaviour.
IIRC with the modern implementation of arrays in the Zend Engine, you can check that an array has no string keys, has keys in the right order, and possibly even that they are all numbered 0 through (count($arr) - 1) without gaps. I recall someone previously suggesting (not formally proposing IIRC) we could have a standard library is_ function to check these, but it didn't go anywhere. Anyway, someone who has touched the code more recently than me would have to confirm (please do!), but I think we could cheaply add a `list` type declaration that just checks for an array fulfilling some or all of these criteria.
Making a special kind of array _value_ that must stay a “list” sounds more problematic… I think without automatic casting back and forth from regular “arrays” it might play badly with existing code, but then there would be no point…
Thanks for the interesting idea! Andrea -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php