Enumerations

What is an enumeration?

See here.

What are enumerations good for?

Enumerations are good for collecting named values in groups. If you have a set of values that keep recurring, consider making them into an enum.

You will ahave to deal with the restriction that constant names have to be identifiers, but if that is doable, then enumerations can be very useful.

How do I create an enumeration?

An example:

CREATE ENUMERATION boolean = {
   false = 0
   true,
}
GO

Can I assign specific values to enumeration constants?

Yes. As in the example above, where "false" gets the value "0".

Can I let Emdros assign values?

Yes. Just don't assign a value. It will be given the value of the previous constant, plus 1. The first constant, if given no value, will be 0.

How do I name enumerations?

You use identifiers.

If your enumeration has the same name as a feature, you can put a "_t" suffix on the enumeration to distinguish it from the feature:

CREATE ENUMERATION phrase_type_t = {
  NP = 1,
  VP,
  AP,
  AdvP,
  PP
}
GO

CREATE OBJECT TYPE
[Phrase
  phrase_type : phrase_type_t;
]
GO

The suffix can be anything, but "_t" is a fairly common ending in programming languages, and can mean "_type". "_e" for "enumeration" would also do. Again: It doesn't matter that much.


Previous:Features
Up:Schema
Next:Summary