| 1 | (* A name of an enumeration may be written with its type; two |
| 2 | enumerations of a scope may share a name, and an enumeration may share |
| 3 | one with another declaration: written alone, the name is that other |
| 4 | one (report 2026-10.31, section 5.7). *) |
| 5 | module EnumNames; |
| 6 | import Out, EnumKinds; |
| 7 | |
| 8 | type |
| 9 | Style = (bold, italic); |
| 10 | Elem = (para, bold, rule); |
| 11 | Light = (red, amber, green); |
| 12 | |
| 13 | const Stop = Light.red; |
| 14 | |
| 15 | var s: Style; e: Elem; ss: set of Style; k: EnumKinds.Elem; |
| 16 | |
| 17 | proc rule; (* beside Elem's rule *) |
| 18 | begin |
| 19 | Out.str("the procedure rule\n"); |
| 20 | end; |
| 21 | |
| 22 | proc main*; |
| 23 | begin |
| 24 | s := Style.bold; e := Elem.bold; |
| 25 | if (s = Style.bold) and (e = Elem.bold) and (INT(e) = 1) then Out.str("Style.bold and Elem.bold\n"); end; |
| 26 | e := para; (* Elem's alone *) |
| 27 | e := Elem.rule; |
| 28 | rule; (* the procedure *) |
| 29 | s := italic; |
| 30 | match e of |
| 31 | | Elem.rule: Out.str("an arm with its type\n"); |
| 32 | | para, bold: Out.str("an arm without\n"); |
| 33 | end; |
| 34 | ss := {Style.bold, italic}; |
| 35 | if Style.bold in ss then Out.str("in the set\n"); end; |
| 36 | if (Stop = red) and (Light.green > amber) then Out.str("ordered\n"); end; |
| 37 | k := EnumKinds.Elem.bold; |
| 38 | if (k = EnumKinds.Elem.bold) and (EnumKinds.Style.bold # EnumKinds.Style.plain) then |
| 39 | Out.str("imported, with module and type\n"); |
| 40 | end; |
| 41 | if EnumKinds.para = k then Out.str("no\n"); end; |
| 42 | end; |
| 43 | |
| 44 | end EnumNames. |