To allow macros to be used like variables the @let directive can be used. This directive has two syntactic forms. When the type is specified, it introduces a name in that scope. Otherwise, it binds to an existing name by searching upwards through nested scopes for a previously defined variable with that name.
Before translation | After translation |
---|---|
|
|
String literals can be given in single or double quotes (and this has no effect on the meaning). The binary ’+’ operator can be used to concatenate strings. However, string variables macroexpand without the containing quotes! This leads to some surprises. To get the quotes the @str directive must be used.
Before translation | After translation |
---|---|
|
|
There is a special syntax to assign a string variable to macroexpanded text. The directive @let x := y is equivalent to @let x = @str(y).