Mark Wood wrote:
I have found that there are some functional differences that Metaware has over
fpc, one example is the yield() function which returns the intermediate result
of a function call.
?
'?' indeed! I am fascinated! What does yield do exactly... presumably
it returns a result from the function without closing down that
instance of the function? Amazing concept. I am still trying to work
out how that could be useful or even how it could be used (without
breaking stuff upstream).
This would be one example, a function which returns a value each time it
is called. There are some scoping rules which dictate whether the
yield'ed function will init or continue from the last yield point:
============== begin ====================
iterator LoopStep(Start, Stop, StepSize : StdInt) : StdInt;
var
i, Answer, NumLoops : StdInt;
begin
if StepSize = 0 then return;
Answer := Start;
NumLoops := ((Stop - Start) DIV StepSize) + 1;
for i := 1 to NumLoops do begin
Yield(Answer);
Answer := Answer + StepSize;
end;
end;
============== snip =====================
Not sure why they found this terribly useful, but I don't write
financial code...
TomW
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net http://cyberiansoftware.com http://openzipit.org
"Windows? No thanks, I have work to do..."
----------------------------------------------------
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal