define_syntax
define_syntax(s_nameg_expander... ) =>s_name
Description
Creates a syntax rule using the syntax_rule expander form.
Arguments
|
Expander form, which can be of the form ( |
Value Returned
|
A macro expression, which evaluates to a single argument procedure that performs the specified syntactic transformation. |
Examples
(define_syntax incf (syntax_rules () ((_ location) (setf location (add1 location)))
((_ location amount) (setf location (plus location amount)))))
=> incf
x=3 => 3
(incf x) => 4
x => 4
(incf x 3) => 7
x => 7
x='(1 2 3) => (1 2 3)
(incf (cadr x)) => 3
x => (1 3 3)
(incf (car x) 5) => 6
x => (6 3 3)
Related Topics
Function and Program Structure
Return to top