-
Notifications
You must be signed in to change notification settings - Fork 8
6.1.1 Macro Functions
Claude Roux edited this page Feb 19, 2024
·
11 revisions
A macro is a function that is applied at compile time to replace a piece of code with another. Macro functions in LispE are based on the same principle as pattern programming as demonstrated with defpat functions.
A macro can be divided into different functions, each with its own set of parameters.
Note that the $
operator in macros are used both in the parameter list and as a specific extensor function in the code.
A macro is a way to replace code with a more complex definition.
; this macro computes the cube of a number:
(defmacro cube(x) (* x x x))
If we apply this macro in a piece of code:
(cube 10)
cube will be replaced with it definition:
(* 10 10 10)
The patterns that are available for defpat