Search code examples
macroscommon-lispparenscript

How to evaluate the code passed to the `parenscript:ps` macro?


How can I evaluate the code passed to the ps macro in Parenscript?

(let ((x 1))
  (format nil "~a" (parenscript:ps x))) 
;; => "x;" but I would like "1;"

I know that ps is a macro and is the reason to not evaluate, but how to can I evaluate the code to passing to ps macro?


Solution

  • Your example using ps:lisp:

    (let ((x 1))
      (format nil "~a" (ps:ps (ps:lisp x))))
    "1;"
    

    It is introduced in the first section of the documentation: https://common-lisp.net/project/parenscript/reference.html#section-ps-compiler