[J3] [EXTERNAL] [BULK] Re: A couple more ideas for features

Brad Richardson everythingfunctional at protonmail.com
Thu Apr 6 15:22:34 UTC 2023


Hi All,

If the suggestion is a shorthand for

DO
...
IF (cond) EXIT
END DO

and not

DO WHILE (.NOT. cond)
...
END DO

then I would suggest actually doing multiple forms. I.e.

DO UNTIL(cond) DO WHILE (.NOT. cond)
... -> ...
END DO END DO

DO DO
... -> ...
UNTIL(cond) IF (cond) EXIT
END DO

DO DO
... -> ...
WHILE(cond) IF (.NOT. cond) EXIT
END DO

I've often wanted the explicit forms of "at least once" loops. Note that DO WHILE is the term used for these in some other languages. I'm open to suggestions for exact syntax of the ending conditionals, as they don't quite seem to clearly signify the END of the loop, but would feel backwards as END WHILE(cond).

Regards,
Brad

On Thu, 2023-04-06 at 15:10 +0000, Clune, Thomas L. \(GSFC-6101\) via J3 wrote:

> Hi David,
>
> EXIT and CYCLE definitely make DO WHILE unnecessary; no argument there. But I have many cases where I consider DO WHILE(cond) to make the loop more intelligible to humans. My guess is that there are far fewer cases where DO … UNTIL provides such additional clarity.
>
> Cheers,
>
> - Tom
>
> From:J3 <j3-bounces at mailman.j3-fortran.org> on behalf of j3 <j3 at mailman.j3-fortran.org>
> Reply-To: David Muxworthy <d.muxworthy at bcs.org.uk>, j3 <j3 at mailman.j3-fortran.org>
> Date: Thursday, April 6, 2023 at 11:06 AM
> To: j3 <j3 at mailman.j3-fortran.org>
> Cc: "d.muxworthy at icloud.com" <d.muxworthy at icloud.com>
> Subject: [EXTERNAL] [BULK] Re: [J3] A couple more ideas for features
>
> CAUTION: This email originated from outside of NASA. Please take care when clicking links or opening attachments. Use the "Report Message" button to report suspicious messages to the NASA SOC.
>
> The DO block was introduced in F90. As I remember the discussions, it was thought that DO ... END DO with EXIT and CYCLE made WHILE and UNTIL unnecessary. However WHILE got added because other languages had it.
>
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230406/6505bfc2/attachment-0001.htm>


More information about the J3 mailing list