Professional Documents
Culture Documents
For example:
fn Main() {}
If you compile this program, you get the compilation error "main function not
found", as no main function (with a lowercase m) is defined in the program.
From now on, except when specified, we will assume the example code will be inside
the braces of the “main” function, and so the braces and the text preceding them will be
omitted.
This statement, put inside the braces of the “main” function, will print again:
"Hello, world!".
In this case, the print macro receives three arguments, separated by commas.
All three arguments are literal strings. The first string, though, contains two pairs of
braces ({}). They are placeholders, indicating the positions in which to insert the other
two strings.
So, the macro scans the arguments after the first one, and for each of them it
looks inside the first argument for a pair of braces, and replaces them with the current
argument.
This resembles the following C language statement:
you get the compilation error "argument never used", as the arguments of the macro
after the first one are more numerous than the placeholders inside the first argument;
that is, there is some argument that doesn't have any corresponding placeholder.
And if you try to compile