Re: [RFC][DISCUSSION] Collection Inspection

From: Date: Mon, 29 Jan 2018 21:30:58 +0000
Subject: Re: [RFC][DISCUSSION] Collection Inspection
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-101725@lists.php.net to get a copy of this message
On Mon, Jan 29, 2018 at 3:26 PM, Rowan Collins <rowan.collins@gmail.com> wrote: > On 29 January 2018 19:14:43 GMT+00:00, Michael Morris <tendoaki@gmail.com> > wrote: > > The is_callable() > >above prevents iteration over generators, potentially consuming them > >for no purpose. > > Unfortunately, it doesn't: it's not the generator definition that you'll > be passed, but the Generator object returned when you run it, and that is > not callable https://3v4l.org/rknQJ > > (The definition is more like a constructor, and I wish it didn't look so > much like a normal function in declaration and use.) > > Nor are generators the only non-rewindable iterables you need to worry > about, so really the only options you have are to only inspect arrays, or > to add a big fat warning that the function may consume your iterable (or > enter an infinite loop). > > Ok, so make no attempt to keep people from shooting themselves in the foot eh? Fine, is this otherwise workable?

« previous php.internals (#101725) next »