Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. (in-package #:let-over-lambda)
  2.  
  3.  
  4. (eval-when (:compile-toplevel :load-toplevel :execute)
  5. (defun make-defmacro (name lambda-list docstring declarations body)
  6. (append (list 'defmacro name lambda-list )
  7. (when docstring (list docstring))
  8. declarations
  9. body))
  10. (defun make-let (bindings body)
  11. (list* 'let bindings body)))
  12.  
  13.  
  14. (defmacro defmacro/g! (name args &rest body)
  15. (let ((syms (remove-duplicates
  16. (remove-if-not #'g!-symbol-p
  17. (flatten body)))))
  18. (multiple-value-bind (body declarations docstring)
  19. (parse-body body :documentation t)
  20. (make-defmacro name args docstring declarations
  21. (list (make-let (mapcar
  22. (lambda (s)
  23. (list s (list 'gensym (subseq (symbol-name s) 2))))
  24. syms)
  25. body))))))
  26.  
  27. (macroexpand-1 '(defmacro/g! moo (a) (list 'list (list 'quote a) (list 'quote a))))
  28. --> (defmacro moo (a) (let nil (list 'list (list 'quote a) (list 'quote a))))
  29. t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement