From e126df0c189d7683a21a3f64eb2512c9a7153f03 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Sat, 22 Dec 2012 02:17:43 +0000 Subject: [PATCH] dolist --- test.lisp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/test.lisp b/test.lisp index 1521b9a..b8bde69 100644 --- a/test.lisp +++ b/test.lisp @@ -36,6 +36,16 @@ (defmacro unless (condition &rest body) `(if ,condition nil (progn ,@body))) +(defmacro dolist (iter &rest body) + (let ((var (first iter)) + (g!list (make-symbol "LIST"))) + `(let ((,g!list ,(second iter)) + (,var nil)) + (while ,g!list + (setq ,var (car ,g!list)) + ,@body + (setq ,g!list (cdr ,g!list)))))) + (defun = (x y) (= x y)) (defun + (x y) (+ x y)) (defun - (x y) (- x y)) @@ -895,6 +905,20 @@ code (setq *toplevel-compilations* nil)))) + +(defmacro with-compilation-unit (&rest body) + `(progn + (setq *env* nil) + (setq *fenv* nil) + (setq *compilation-unit-checks* nil) + ,@body + (dolist (check *compilation-unit-checks*) + (funcall check)) + (setq *env* nil) + (setq *fenv* nil) + (setq *compilation-unit-checks* nil))) + + #+common-lisp (progn (defun read-whole-file (filename) @@ -926,6 +950,3 @@ (defun eval (x) (js-eval (ls-compile x nil nil))) - - -(debug (ls-compile 'x nil nil)) -- 1.7.10.4