Ferenc Kovacs wrote:
it doesn't make a difference, if you yield only once, and put that into a loop, or copy paste the yield line ten times. yield always does the same thing, pass the execution to the caller.
I KNOW that I am sounding thick here but "you don't have to understand the underlying process, as it 'just works'." is exactly where I'm having the problem. Perhaps because some of these things ARE treated as 'magic' ? But I need to understand the work flow if I'm going to profile it and optimise use of this stuff. When working on data feeds from the database, HOW is everything in making it work at it's fastest. One way of doing things can be several orders of magnitude slower than another.
In this example, if I look at it as an SQL stored procedure, on every 'pass back to the caller' I get the next piece of data, so I'm getting a sequence of all the 'first' objects, followed by all the 'second' objects. What is consuming that data just takes what is given each time and processes it. Somewhere in this magic, the data is packaged so it can be passed, and it's yield that is packaging the return. In SQL that return would be a database record each time, with no relation to previous or next record, but I presume talk of 'auto-increment' is to automatically add a record count? And talk of 'returning arrays' only applies if 'yield' specifically outputs the next array element? It's this 'just looks like an array' that is getting me since the whole point is NOT to return an array of objects? In my method of working I can either build an array of records from the data feed, or simply handle each item in a sequence and throw it away. You don't want to build the array was the reason given for needing generators?
-- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php