On Tue, Aug 5, 2025 at 9:43 AM Greg Wilburn
<gwilburn@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

To me, this is more readable:
c if %eof or
c (wsprms>0 and (accom#<>p1com# or acent#<>p1ent#))
c leave
c endif

I'm sure it has something to do with my education (Physics/Math)

I think it can affect anyone regardless of background. There is
nothing wrong with syntactically unnecessary parentheses. If they
reduce the chance for ambiguity, there's some value to them.
Personally, I agree that your proposed parens would be an improvement.

Personally, I prefer my loops to be more explicit:

setll (key1:key2) recordformat;
dou %eof(myfilename);
reade (key1:key2) recordformat;
if not %eof(myfilename);

...STUFF...

endif;
enddo;

Here I am more with cesco: I don't think this style is "wrong" or
"bad" but it is definitely verbose; and to me, the logic of it doesn't
feel "tight".

It feels kind of heavy (if not downright excessive) to have to test
%eof twice so close together. Conceptually, you should only have to
test %eof once per iteration.

The infinite loop that is exited upon %eof doesn't feel in any way
"not explicit" to me. It's arguably the most direct way in RPG to
express the plain-English idea "just keep going until you run out of
data".

I will say your version is perhaps the "least heavy" of the
leave-averse ones. The only other option for avoiding the double %eof
test is to have a pre-loop read as well as an in-loop read (which is
what cesco described).

It's really just a matter of acclimation. The fact that the very first
thing in a typical "dow '1'" or "dow *on" loop is a read followed by
an %eof test is, to me, a very clear statement of intent.

I mean, even if the test-and-leave isn't right up front, I think we
can reasonably assume that the author didn't intend for the program to
hang. So if there's an infinite loop, then it's very clear (i.e.
obvious, i.e. tantamount to explicit) that there was supposed to be
some way to get out of it.

Maybe it helps to leverage the math background: Remember recurrence
relations and induction? I know many "mathy" people find recursion a
very natural way to program, because it's the computing analog to
induction. It feels more functional and less imperative. And what's
recursion? It's an infinite loop, where (typically) the very first
thing you do is check whether you're done.

John Y.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.