Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (in-package #:let-over-lambda)
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (defun make-defmacro (name lambda-list docstring declarations body)
- (append (list 'defmacro name lambda-list )
- (when docstring (list docstring))
- declarations
- body))
- (defun make-let (bindings body)
- (list* 'let bindings body)))
- (defmacro defmacro/g! (name args &rest body)
- (let ((syms (remove-duplicates
- (remove-if-not #'g!-symbol-p
- (flatten body)))))
- (multiple-value-bind (body declarations docstring)
- (parse-body body :documentation t)
- (make-defmacro name args docstring declarations
- (list (make-let (mapcar
- (lambda (s)
- (list s (list 'gensym (subseq (symbol-name s) 2))))
- syms)
- body))))))
- (macroexpand-1 '(defmacro/g! moo (a) (list 'list (list 'quote a) (list 'quote a))))
- --> (defmacro moo (a) (let nil (list 'list (list 'quote a) (list 'quote a))))
- t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement