Re: RFC - Array Of for PHP 7

From: Date: Fri, 27 Oct 2017 12:35:56 +0000
Subject: Re: RFC - Array Of for PHP 7
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-100965@lists.php.net to get a copy of this message
On 25 October 2017 22:52:37 BST, Dan Ackroyd <danack@basereality.com> wrote: >Although 'array of' as well as full blown generics are popular ideas, >I'm pretty certain the RFC failed due to the type check on the array >happening every time the 'array of' was passed from one function to >another, which would make it too slow to actually use. The fundamental problem with extending PHP's type declarations - either to more complex types, or to other code elements such as properties - is that they are currently always checked at run-time, not with a separate static analyser. It's notable that in Go, the runtime type checks are considered a "development only" option, and strongly discouraged in production code due to performance impact. I wrote about this a few months back here: http://rwec.co.uk/q/php-type-system One possibility if we do want to keep the current run-time approach is to cache type information against values (zvals) so subsequent checks become quicker. The problem is working out exactly what to store and when to invalidate it - if you append 42 to an array that passed int[] on the last check, the ideal would be for us to know the type is still valid. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#100965) next »