I'm trying to eval a list with variables inside a macro function that defines a variable in a lambda but the eval in it can't
(define-syntax MYVAR
(syntax-rules ()
[(_ varname value body ...) ((lambda (varname) body ...) value)]))
(define mylist '(list P Q))
(print mylist)
(MYVAR P 1
(MYVAR Q 2
(print P Q) ;;everything prints fine in here
(print (eval mylist))))
<eval> ((lambda2127 (P) (MYVAR Q 2 (print P Q) (print (eval mylist)))) 1)
<eval> ((lambda2129 (Q) (print P Q) (print (eval mylist))) 2)
<eval> (print P Q)
<eval> (print (eval mylist))
<eval> (eval mylist)
<syntax> (list P Q)
<eval> (list P Q) <--
=> Error: unbound variable: P
I assume eval tries to evaluate before my macro compiles but not sure,
is there a way to reuse a list and evaluate it inside a macro?
I have tried to use define-for-syntax
but the same error arises