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

Go to the source code of this file.
Macros | |
| #define | ML99_choice(tag, ...) ML99_call(ML99_choice, tag, __VA_ARGS__) |
| Constructs an instance of a choice type. | |
| #define | ML99_choiceTag(choice) ML99_call(ML99_choiceTag, choice) |
Evaluates to the tag of choice. | |
| #define | ML99_choiceData(choice) ML99_call(ML99_choiceData, choice) |
Evaluates to the data of choice. | |
| #define | ML99_match(choice, matcher) ML99_call(ML99_match, choice, matcher) |
Matches the instance choice of a choice type. | |
| #define | ML99_matchWithArgs(choice, matcher, ...) ML99_call(ML99_matchWithArgs, choice, matcher, __VA_ARGS__) |
| The same as ML99_match but supplies additional arguments to all branches. | |
| #define | ML99_CHOICE(tag, ...) (tag, __VA_ARGS__) |
| #define | ML99_CHOICE_TAG(choice) ML99_PRIV_HEAD_AUX choice |
| #define | ML99_CHOICE_DATA(choice) ML99_PRIV_TAIL_AUX 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, | |
| ... | |||
| ) | ML99_call(ML99_choice, tag, __VA_ARGS__) |
Constructs an instance of a choice type.
~ if you do not want to supply data; then, to match it, write a _ parameter to ignore. | #define ML99_choiceData | ( | choice | ) | ML99_call(ML99_choiceData, choice) |
Evaluates to the data of choice.
This macro is essentially the same as ML99_tupleTail.
| #define ML99_choiceTag | ( | choice | ) | ML99_call(ML99_choiceTag, choice) |
Evaluates to the tag of choice.
This macro is essentially the same as ML99_tupleGet(0).
| #define ML99_match | ( | choice, | |
| matcher | |||
| ) | ML99_call(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, | |||
| ... | |||
| ) | ML99_call(ML99_matchWithArgs, choice, matcher, __VA_ARGS__) |
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...).