mark multi-form macro expansions with $
A bare list was read as several forms, so a macro returning `((make-adder 10) 5)' -- a call of what make-adder returns -- was spliced into two. Add a new $ char to denote splicing, so ($ form ...) splices.
This commit is contained in:
14
Readme.org
14
Readme.org
@@ -212,6 +212,20 @@ Sex has support for syntactic macros. Macro definitions look like
|
||||
functions: they have a name, an argument list and a body. Macro should
|
||||
return Sex code.
|
||||
|
||||
A macro returns *one* form. To return several --- a function beside the
|
||||
struct it works on, say --- return them under =$=, which splices them in
|
||||
where the macro was written:
|
||||
|
||||
#+begin_src scheme
|
||||
(defmacro (pair-of-fns a b)
|
||||
`($ (fn ,a () int (return 1))
|
||||
(fn ,b () int (return 2))))
|
||||
#+end_src
|
||||
|
||||
=($)= expands to nothing. Everything else is a single form, including
|
||||
one whose head is itself a form: =`((make-adder 10) 5)= calls what
|
||||
=make-adder= returned, and is not two forms.
|
||||
|
||||
*** Examples:
|
||||
**** Structure with templated value type
|
||||
#+begin_src scheme
|
||||
|
||||
Reference in New Issue
Block a user