-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmacro.tem
21 lines (21 loc) · 1.3 KB
/
macro.tem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(page "Macros"
(newtable "Macros"
(import "docs/macro0.html")
(mac mac "name args [body ...]" "Creates a macro." (tests (mac mymac (a b) (+ a b))))
(op macex "macro" "Expands a macro."
(tests (macex '(let a 1 (pr a)))))
(op macex1 " macro" "Expands a macro to one level."
(tests (macex1 '(let a 1 (pr a)))))
(op uniq " " "Generates a unique symbol."
(tests (uniq)))
(mac w/uniq "names [body ...]" "Assigns a unique symbol to each name in <code>names</code> and executes <code>body</code>. <code>names</code> can either be a single symbol or a list of symbols." (tests (w/uniq (a b c) (prn a b c))))
(op quasiquote "arg" " The backquote <code>`</code> is shorthand for <code>quasiquote</code>, e.g. <code>`(+ 1 2)</code> is the same as <code>(quasiquote (1 2))</code>. Inside <code>quasiquote</code>, the <code>unquote</code>
operator will cause the contents to be evaluated instead of quoated. The
<code>unquote-splicing</code> operator will cause contents to be evaluated and spliced
into the result. <code>,</code> is shorthand for <code>unquote</code>, and <code>,@</code> is shorthand for
<code>unquote-splicing</code>."
(tests `((+ 1 2) ,(+ 3 4) ,@(list 5 6))))
(op quote "arg" " The single quote ' is shorthand for quote, e.g. 'x is the same as (quote x) "
(tests '(1 2 3)))
)
)