|
Metalang99 1.13.5
Full-blown preprocessor metaprogramming
|
Choice types: (tag, ...). More...

Go to the source code of this file.
Macros | |
| #define | ML99_choice(tag, ...) |
| Constructs an instance of a choice type. | |
| #define | ML99_choiceTag(choice) |
Evaluates to the tag of choice. | |
| #define | ML99_choiceData(choice) |
Evaluates to the data of choice. | |
| #define | ML99_match(choice, matcher) |
Matches the instance choice of a choice type. | |
| #define | ML99_matchWithArgs(choice, matcher, ...) |
| The same as ML99_match but supplies additional arguments to all branches. | |
| #define | ML99_CHOICE(tag, ...) |
| #define | ML99_CHOICE_TAG(choice) |
| #define | ML99_CHOICE_DATA(choice) |
Choice types: (tag, ...).
A choice type, also known as tagged union, is represented as (tag, ...), where tag is the type of a value and ... is the value. Perhaps the most common example of a choice type is a binary tree:
| #define ML99_CHOICE | ( | tag, | |
| ... ) |
| #define ML99_choice | ( | tag, | |
| ... ) |
Constructs an instance of a choice type.
| #define ML99_CHOICE_DATA | ( | choice | ) |
| #define ML99_CHOICE_TAG | ( | choice | ) |
| #define ML99_choiceData | ( | choice | ) |
Evaluates to the data of choice.
This macro is essentially the same as ML99_tupleTail.
| #define ML99_choiceTag | ( | choice | ) |
Evaluates to the tag of choice.
This macro is essentially the same as ML99_tupleGet(0).
| #define ML99_match | ( | choice, | |
| matcher ) |
Matches the instance choice of a choice type.
This macro results in ML99_call(ML99_cat(matcher, ML99_choiceTag(choice)), <choice data>).
| #define ML99_matchWithArgs | ( | choice, | |
| matcher, | |||
| ... ) |
The same as ML99_match but supplies additional arguments to all branches.
This macro results in ML99_call(ML99_cat(matcher, ML99_choiceTag(choice)), <choice data>, args...).