Jump to content

Enumerations: Difference between revisions

Line 272:
=={{header|ATS}}==
 
The wording of the task isseems centered on C-centric, where an '''enum''' is a sortnotation offor integertype '''int''', but it is true that the following type will be translated by the ATS compiler to C integers:
 
<lang ATS>datatype my_enum =
Line 279:
| value_c</lang>
 
Within ATS itself, it is a special case of recursive type definition. Similar facilities are available in ML dialects and other languages.
To do it with explicit values, I would simply define some constants, probably with '''#define''' (so I could use them in static expressions, etc.):
 
To do it"enumerate" with explicit integer values, I would simply define some constants, probably with '''#define''' (so I could use them in static expressions, etc.):
<lang ATS>#define value_a 1
#define value_b 2
1,448

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.