Re: [RFC][DISCUSSION] Collection Inspection

From: Date: Mon, 29 Jan 2018 21:26:10 +0000
Subject: Re: [RFC][DISCUSSION] Collection Inspection
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-101723@lists.php.net to get a copy of this message
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). Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#101723) next »