From b5aec2ed7b744cf16fe94b67203d4301ad5ae2ae Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Sat, 15 Dec 2012 18:16:47 +0000 Subject: [PATCH] Add eval-when-compile --- lispstrack.lisp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lispstrack.lisp b/lispstrack.lisp index 9efa0bc..914d00e 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -92,18 +92,18 @@ body can access to the local environment through the variable env" (define-compilation debug (form) (format nil "console.log(~a)" (ls-compile form env))) -(defun compile-test () - (with-open-file (in "test.lisp") - (with-open-file (out "test.js" :direction :output :if-exists :supersede) - (loop - for x = (read in nil) while x - do (write-string (concat (ls-compile x) "; ") out))))) - (define-compilation while (pred &rest body) (format nil "(function(){while(~a){~a}})() " (ls-compile pred env) (ls-compile-sexps body env))) +(defmacro eval-when-compile (&body body) + `(eval-when (:compile-toplevel :execute) + ,@body)) + +(define-compilation eval-when-compile (when &rest body) + (eval body)) + ;;; aritmetic primitives (define-compilation + (x y) (concat "((" (ls-compile x env) ") + (" (ls-compile y env) "))")) @@ -136,3 +136,13 @@ body can access to the local environment through the variable env" (funcall (ls-compile (car sexp) env) ) ;; funcall ))))) + + +;;; Testing + +(defun compile-test () + (with-open-file (in "test.lisp") + (with-open-file (out "test.js" :direction :output :if-exists :supersede) + (loop + for x = (read in nil) while x + do (write-string (concat (ls-compile x) "; ") out))))) -- 1.7.10.4