Defining and using MacrosΒΆ

Macros are small code snippets that do not represent a colon word for itself but the code is used verbatim in other definitions. To use them, include the file lib/macro.frt (requires evaluate.frt and amforth version 4.7ff)

>  macro square " dup *"
ok
>  : foo 5 square . ;
ok
>  foo
25  ok

square can be called just like a word definition as well.

> 6 square .
36 ok
>

There is only one drawback: the macro string cannot contain the delimiting character itself. You’re free to choose any character however

>  macro square2 _ dup *_
ok
>  5 square2 .
25  ok
>