Dodo doc > Macros and Templates > Simple Macro
A simple macro consists of the keyword "wrap" followed by a regular expression and a block for the body of the macro. The regular expression defines the macro and the body contains the substitution. Existing macros are applied to the substitution.
Examples:
wrap /foo/: bar. wrap /kk+/ { kk }
A macro can be declared in any declaration block, but it is normally declared at the top level of a module.
The scoping rules are the same as other declarations.
In the module itself the macro can be used directly. In other modules it needs to be preceded with the name of the module, unless a "use" statement for this module is in scope.
A macro cannot occur in the middle of an identifier or a literal.
Examples:
use foo_module def b = foo # replaced with bar kk_module kkkkk #replaced with kk
Note: if instead of a module the macro is declared in a type and this type is polymorphic, the macro only applies to an object of this type if the compiler can tell the object type statically.