[J3] 21-120r2: Discussion on the feasibility of any future enhancement of Enumeration Type

Vipul Parekh parekhvs at gmail.com
Tue Mar 2 06:21:42 UTC 2021


Hi Malcolm,

Re:  Ondřej's question at the plenary today (Monday, March 1, 2021) as to
feasibility of any future enhancement of Enumeration Type and where he
mentioned me, can you please take a look at the scenario below?

Consider the 'w_value' example from 21-120r2:

Enumeration Type :: w_value
   Enumerator :: w1, w2, w3, w4, w5, wendsentinel
End Enumeration Type

Now consider 'Type(w_value) :: w = wendsentinel' and 'x = INT(w)'.
Paper 120-r2 suggests x will have the value of 6, correct?.

Now, say in the future (Fortran 202Y or later), an enhancement is
proposed that seeks to allow a programmer to instead author a
*Fortran-only* (i.e., no BIND(C)) enumeration type as shown below: you
will note this is pertinent to Ondřej's question because he brought up
my name and I have requested such facility in paper 19-229:

Enumeration Type :: w_value
   Enumerator :: w1=0, w2, w3, w4, w5, wendsentinel = 65535
End Enumeration Type

Here, please note the changes in 'w1' thru' 'w5' and with 'wendsentinel'.

Let us consider again 'Type(w_value) :: w = wendsentinel' and 'x = INT(w)'.

What will be the value of x in this second scenario?  If it remains as
6 or if it were to change be 65535, it will be rather confusing to
programmers because why would a 'conversion' result in either of the
values.  But now, if type conversion to INT were to be disallowed
under the new circumstance, it too will be odd and confusing because
Fortran 202X would have introduced it.

Owing to this problem, a future committee is highly unlikely to allow
any changes that Ondřej was asking you about.

Hence the concern I mentioned at the plenary that the type conversion
you include under point (b) under 2.2 Specifications in 21-120r2
pretty much closes the door on any revision along the lines of what I
have been requesting .  And the chances a committee would consider a
third feature toward what is commonly understood as 'enums' aka
'enumeration types' will be nil.

Instead of 'type conversion' in 21-120r2 using INT intrinsic, should a
simple ORDINAL function be introduced that would permit 'x =
ORDINAL(w)', there should be no confusion now or later, the value of
'x' will be the ordinal and in both the two scenarios I show above,
'x' can remain 6.

Thanks,

Vipul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210302/e39b0ae6/attachment.htm>


More information about the J3 mailing list