Rasmus Lerdorf wrote:
So how about something like this:

generator function f() {
   echo "Hello World";
}

generator function f() {
   return 1;
}

generator function f($arg) {
   if(f!$arg) yield 1;
   else if($arg<0) return 1;
   else return;
}

What does the generator keyword mean in each of these cases? Anything?
Nothing? Would I see a difference either at compile-time or at execute
time if I left it out?

Well the same could be said of some of the error messages generated by 'static' if E_STRICT is enabled. However an error on the first two saying 'no yield point found' would not be unreasonable. In reality a lot of this should simply be handled by a good IDE leaving the runtime code as clean as possible?

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.

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