RCML supports macros. A macro is a combination of an identifier – macro name – random text –macro contents. The macros are declared in the section of declarations by define keyword, followed by a separator, followed by an identifier (macro name), a separator again and macro text.

Macro syntax:

define macro_name macro_contents

All occurrences of the macro name in the text of the section of functions will be replaced by its contents. After defining a macro can not be re-defined by other macros.

The macro content includes any text between the separator character following the macro name and the line end. Macros can have multi-line content (use «\» character, i.e., shield the line end, as it is done in multi-line macros in C++). Then the macro content will be considered as the text until the end of the line following the line ending with this character. Line feed characters in multi-line macros are preserved.

Example use of macros

define ONE 1
define TWO 2
define TREE ONE + \
define TEST_MS "test message"

function main(){
	system.echo("1 = ",ONE,"\n");
	system.echo("2 = ",TWO,"\n");
	system.echo("3 = ",TREE,"\n");
	system.echo("Test print > ",TEST_MS,"\n");

This text after macros processing will be converted to the following text:

function main(){
	system.echo("1 = ",1,"\n");
	system.echo("2 = ",2,"\n");
	system.echo("3 = ",1 + 
2 ,"\n");
	system.echo("Test print > ","test message","\n");

The resulting text will already be compiled into the byte code. The result of this program will be as follows:

1 = 1.000000
2 = 2.000000
3 = 3.000000
Test print > test message
Important! It is dangerous to use macros, which recursively refer to each other. In this case, an infinite recursion occurs, which will cause the compiler crash. At this stage of language development, closed recursion in macros cannot be found.

Example closed recursion:

define ONE TWO
define TWO ONE