To: J3 J3/25-198 From: Malcolm Cohen Subject: US14 Scoped enumerator access, edits Date: 2025-October-24 Reference: 23-197, 25-180, 25-007r1. 1. Introduction This paper contains the edits for US14 "Provide scoped access to enumeration enumerators". The formal requirements, specifications, and syntax, are in 25-180. 2. Edits to 25-007r1 [xv] Introduction, Data declaration bullet, insert sentences "The accessibility of an enum-type-name can be specified in its enum-def-stmt. The accessibility of an enumerator in an enum-def or enumeration-type-def can be specified in its enumerator-def-stmt or enumeration-enumerator-stmt, respectively.". [xv] Introduction, Data usage and computation bullet, insert sentence "The value of an enumerator of an enum type or an enumeration type can be accessed via the name of the type, as if it were a component.". [102:16] 7.6.1 Interoperable enumerations and enum types, In R760 enum-def-stmt, insert new productions "or ENUM, BIND(C), access-spec :: enum-type-name or ENUM, access-spec, BIND(C) :: enum-type-name". {We could do a more complicated and more general-looking BNF, but that would just be more work. This is simple and effective.} [102:17] Same subclause, Change "R761 enumerator-def-stmt is ENUMERATOR [ :: ] enumerator-list" to "R761 enumerator-def-stmt is ENUMERATOR [ [ , access-spec ] :: ] enumerator-list". [102:29] Same subclause, p2, append new sentence: "The accessibility of an enumerator name is determined as specified in \ref{D5:Accessibility attribute}.". {That is "in 8.5.2" presently.} [102:30] Same subclause, p3, after "that name." insert new sentence: "The accessibility of an enum type name is determined as specified in \ref{D5:Accessibility attribute}.". [104:1-lots] Same subclause, NOTE 6, After the definition of type myenum, insert "Public :: myenum, one, two, three" In the definition of type flags, insert ",Public" after "Bind(C)", and insert ",Public" after "Enumerator". {Show both ways of specifying accessibility.} Note: this makes the specification part of enum_mod look like "Enum,Bind(C) :: myenum Enumerator :: one=1, two, three End Enum Public myenum, one, two, three Enum,Bind(C).Public :: flags Enumerator,Public :: f1 = 1, f2 = 2, f3 = 4 End Enum" [105:3] 7.6.2 Enumeration types, change "R769 enumeration-enumerator-stmt is ENUMERATOR [ :: ] enumerator-name-list" to "R769 enumeration-enumerator-stmt is ENUMERATOR [ [ , access-spec ] :: ] enumerator-name-list". [105:7-9] Same subclause, p2, replace entire paragraph "The access-spec on an ENUMERATION TYPE statement specifies the accessibility of the enumeration-type-name and the default accessibility of its enumerators. The accessibility of an enumerator may be confirmed or overridden by an access-stmt." with "The accessibility of an enumeration type name and its enumerator names is determined as specified in \ref{D5:Accessibility attribute}.". {Replace redundant specification with reference.} [113:18] 8.5.2 Accessibility attribute, p2, After "derived type name." insert new statements: "An access-spec in an enum-def-stmt specifies the accessibility of the enum type name. An access-spec in an enumerator-def-stmt or enumeration-enumerator-stmt specifies the accessibility of the enumerators defined by that statement.". [146:7+] 9.1 Designator, R901 designator, insert new production alphabetically, "or scoped-enumerator-value". {I chose "scoped-" because that is what we've been calling it, but some other, perhaps more descriptive, prefix could be used. For example, "qualified-" would work as the enumerator name is being "qualified" by the enum or enumeration type name. Note that both enumeration types and enum types have "enumerators", so we only need one production to cover both. Unless, of course, we *want* to draw a distinction.} [150:9-] 9.4 Scalars, just before 9.5 Arrays, insert new subclause "9.4.6 Scoped enumerator values R916a scoped-enumerator-value is type-name % enumerator-name C923a The type-name in a scoped-enumerator-value shall be the name of an enum type or an enumeration type. C923b The enumerator-name shall be the name of one of the enumerators defined in the type's enum-def or enumeration-def. A scoped-enumerator-value has the type, type parameters, and value of the enumerator. The enumerator name need not be accessible in the scoping unit. NOTE For example, given the module Module traffic_signal_m Enumeration Type, Public :: traffic_signal Enumerator, Private :: off, green, amber, red End Enumeration Type End Module then with Use traffic_signal_m, signal => traffic_signal Type(signal) light enumeration values can be accessed and assigned as follows: light = signal%amber". ===END===