Re: Consolidation of Traversable and array operations

From: Date: Thu, 16 Jul 2015 13:08:42 +0000
Subject: Re: Consolidation of Traversable and array operations
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-87199@lists.php.net to get a copy of this message
Hi! On Thu, Jul 16, 2015 at 6:39 PM Michael Wallner <mike@php.net> wrote: > On 16/07/15 11:26, Rowan Collins wrote: > > Benjamin Eberlei wrote on 15/07/2015 21:19: > >> > >> But instanceof and anything related to Reflection or get_class or > >> relevant code will fail on array. > > > > > > Ah, yes, I hadn't thought of reflection type things. I don't think > > instanceof would be a problem, because checking for any class or > > interface other than Traversable would correctly return false; not sure > > if it would make sense for "array() instanceof Traversable" to return > > true or not... > > > > Maybe some pseudotype like callable (e.g. iteratable) makes more sense > then? > I'm okay with a pseudo type. My opinion on the matter at this point is such that I care more about providing an API of sorts to support both kinds of structures, so that any developer can write an extension that can leverage this capability and make this available in user-land. Having array_some() and array_every() support this doesn't have to be documented for all I care, if anything it serves as an example of what can be done. The most immediate feedback I would like is: a) whether it's useful to add as an API, b) a review of the code in php_traversal.[ch] > > -- > Regards, > Mike > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#87199) next »