[J3] [EXTERNAL] Re: Input/Output for enumerators

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Mon Oct 11 22:07:18 UTC 2021


Perhaps a slightly more common scenario than an alphabetizing colleague:     Using enumerators to delineate the error codes for a library.     Often these are broken into groups of semi-related errors, and new error codes introduced in any but the final group would introduce a similar problem.

Admittedly, I’m not sure there is much call to _read_ error codes, so it may not be all that compelling even if it is more common.


From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of j3 <j3 at mailman.j3-fortran.org>
Reply-To: j3 <j3 at mailman.j3-fortran.org>
Date: Monday, October 11, 2021 at 5:16 PM
To: Gary Klimowicz <gak at pobox.com>, j3 <j3 at j3-fortran.org>
Cc: Van Snyder <van.snyder at sbcglobal.net>
Subject: [EXTERNAL] Re: [J3] Input/Output for enumerators

On Mon, 2021-10-11 at 13:06 -0700, Gary Klimowicz wrote:
I assume most program authors, and most users of their programs, would find enumerators' names to be more readable, and especially more reliable. Otherwise, output from one run of a program is not suitable as input to a later run, if  the list was changed (say, alphabetized, or an enumerator added or removed) in the type definition. Using the  ordinal position allows silently incorrect input that is impossible for the program to detect.

This seems compelling to me. A programmer changing of the ordinal values for enumerations shouldn't  be taken lightly, as it affects sort order. Bu I can imagine a lot of scenarios where I might insert a new enumeration value between two existing ones. That would certainly cause some surprising issues if I were to read the previous version's values.

I had a colleague who had an obscession with alphabetizing declarations in each scoping unit he worked on. So I can imagine the sort order of enumerators being changed in the definition of an enumeration type. Somebody might have written the enumerators for color in wavelength order -- red, orange, yellow, green, blue, violet -- only later to have somebody alphabetize them.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20211011/da8d93d2/attachment-0002.htm>


More information about the J3 mailing list