On 2020-01-14, at 17:47:46, Glenn Knickerbocker wrote:
> ...
> So beware--don't let a STREAMSTATE SUMMARY lead you to run too far.
>
> 'streamstate summary'
> If rc = 0 Then 'peekto'
> Do While rc = 0
> 'callpipe *: | take' etc.
> If rc = 0 Then 'streamstate summary'
> If rc = 0 Then 'peekto'
> End
>
I have long been uncomfortable with top-and-bottom testing.
I believe it's confusing and an invitation to errors in
maintenance. So:
Do PeekLoop = 1
'streamstate summary'
If rc = 0 Then 'peekto'
If rc = 0 Then 'callpipe *: | take' etc.
Else Leave PeekLoop /* If any comand failed. */
End PeekLoop
I believe this is semantically equivalent.
o No, I don't consider "Leave" ill-structured. It's
not like Signal.
o I believe a loop should have a single exit condition,
not separate (even if equivalent) entry and exit
conditions.
An alternative, eliminating "Leave" (although it sets the
exit condition both outside and inside the loop) might be:
rc = 0
Do PeekLoop = 1 while rc == 0
'streamstate summary'
If rc = 0 Then 'peekto'
If rc = 0 Then 'callpipe *: | take' etc.
End PeekLoop
-- gil