In the context of reverse communication, Ted Stern <[log in to unmask]>
mentioned alternate returns.
A loop to be used with reverse communication, would become:
what = 0
do
call routine ( what, x, answer, *100, *200, *300 )
exit
100 continue
! Do thing 1
cycle
200 continue
! Do thing 2
cycle
300 continue
! Do thing 3
end do
This is OK for the calling routine (I still prefer a SELECT CASE on WHAT,
since you need WHAT anyway to say "I'm starting a new problem").
But it doesn't do anything for the called routine. The big problem with
reverse communication is getting back, in the called routine, to where
access to user code was needed. As John Venier has pointed out, it's
usually not as simple as a SELECT CASE or a computed GO TO. Access to user
code is frequently needed inside of a loop, or an IF. Getting back to
the point after the need for access to user code can't be done by a
SELECT CASE in those circumstances -- it needs a GO TO. Since one can't
GO TO into a loop or IF, those in turn also become implemented by GO TO.
The clean answer is the coroutine.
With corouties, one might want to be able to use alternate coreturns.
If they were available, the CYCLE statements in the above example would
become COCALL statements (and the WHAT variable is no longer needed
because CALL instead of COCALL sends control to the first statement
of ROUTINE).
John Venier surmised correctly that coroutines are a very old idea.
Best regards,
Van Snyder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|