From: David Vazquez Date: Sun, 16 Dec 2012 23:31:11 +0000 (+0000) Subject: DEFUN macro X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=0352e2cff01edf1853e4db7d64b8ae6d94807d25;p=jscl.git DEFUN macro --- diff --git a/lispstrack.lisp b/lispstrack.lisp index 44be5a6..7b5fbf9 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -301,6 +301,7 @@ ((symbolp x) (lookup-function x fenv)))) +#+common-lisp (defmacro eval-when-compile (&body body) `(eval-when (:compile-toplevel :execute) ,@body)) @@ -350,6 +351,9 @@ (backquote-expand-1 (cadr form)) form)) +(defmacro backquote (form) + (backquote-expand-1 form)) + (define-transformation backquote (form) (backquote-expand-1 form)) diff --git a/test.lisp b/test.lisp index 6d386cb..3abd8f5 100644 --- a/test.lisp +++ b/test.lisp @@ -1,3 +1,20 @@ +;;; Library + +(eval-when-compile + (%compile-defmacro 'defmacro + (lambda (name args &rest body) + `(eval-when-compile + (%compile-defmacro ',name (lambda ,args ,@body)))))) + +(defmacro defun (name args &rest body) + `(progn + (eval-when-compile + (%compile-defun ',name)) + (fsetq ,name (lambda ,args ,@body)))) + + +;;; Tests + (lambda (x y) x) (debug "hola") @@ -26,12 +43,7 @@ ;;; Macros (debug "---MACROS---") -(eval-when-compile - (%compile-defmacro 'defmacro - (lambda (name args &rest body) - (list 'eval-when-compile - (list '%compile-defmacro (list 'quote name) - (list* 'lambda args body)))))) + (defmacro incf (x) (list 'setq x (list '+ 1 x))) @@ -69,15 +81,9 @@ (debug (lambda (x y &rest z) x)) -(progn - (eval-when-compile - (%compile-defun 'f)) - (fsetq f (lambda (x) (* x x)))) - +(defun f (x) (* x x)) (debug (f 33)) -;; (debug (foo)) - ;; (eval-when-compile ;; (%compile-defmacro 'defun ;; (lambda (name args &rest body)