Morgan L. Owens wrote:
For the third one ... I'm still waiting for some clarification on how
yield is SUPPOSED to work anyway? If you are using a 'generator' to
return a sequence of data elements, then just what does happen between
each call to the generator ... DOES the generator get called for each
value until something flags there are no more? I still don't see the
advantage of restructuring how things are called to get around a problem
which can just as easily be solved by proper design in the first place.

Have you even read the RFC yet? Calling a generator function returns an instance
of a Generator object. That object has a method interface - described in the
RFC. That interface is accessible to the foreach() construct so the loop can
iterate over the successive values returned by the object.

If by "proper design" you mean your own personal preference for using callbacks,
that's also discussed in the RFC. You were told this last month:

You see that is my problem ... WHY is using an existing object instance so 
wrong?

$handle = fopen("../data/clientdatabase.csv", "r");
if ( $handle == FALSE) {
        $row = -999;
} else {
        while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
        if ( $row ) $contact->ContactRecordLoad( $data );
        $row++;
        }
        fclose($handle);
}

$contact->ContactRecordLoad( $data ); simply processes the data and then throws it away, so why is this so bad? I am just trying to understand why my long time method of working is so frond upon, and understand if generators will improve the performance of the above 'very heavy' code. ContactRecordLoad identifies the 'line type' and then extracts the data based on the line type. My NLPG data importer has a dozen processor functions selected by the base 'RecordLoad', normally the only problem area is translating different date formats into something generic, so the basic iteration loop isn't a problem. How will the use of 'yield' make this better? Or more important - based on the rfc - why is this so wrong?

--
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

Reply via email to