Skip to content

defmacro in Lisp REPL #6

Closed Answered by mythz
rectalogic asked this question in Q&A
Discussion options

You must be logged in to vote

That's the correct syntax, but the problem is running in the x lisp REPL where the expression is wrapped in an implicit scoped return.

You can avoid the implicit scoped wrapping by wrapping it in your own (return) expression, e.g:

x lisp
> (return (defmacro 2+ (n) `(+ ,n 2)))
> (sum (map 2+ [1 2 3]))

You can also paste the expression as-is:

(defmacro 2+ (n) `(+ ,n 2)) (sum (map 2+ '(1 2 3)))

in any LISP textarea on https://sharpscript.net, e.g: https://sharpscript.net/linq/restriction-operators?lang=lisp

It's one of the fundamental building blocks in #Script LISP that's used to implement many of its core constructs, e.g:

; defined by
(setq defmacro
      (macro (name args &rest body)
    …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rectalogic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants