Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro macro-result ((&rest let-args) &body body)
- (let ((argument-info (map 'list (lambda (let-arg)
- (list (first let-arg) (gensym) (second let-arg)))
- let-args)))
- (if (null argument-info)
- ``(progn ,@',body)
- `(let ,(loop :for argument-tuple :in argument-info
- :collect `(,(second argument-tuple) ,(third argument-tuple)))
- `(let ,(list ,@(loop :for argument-tuple :in argument-info
- :collect ``(,',(first argument-tuple) ,,(second argument-tuple))))
- ,@',body)))))
- (defun generate-code-inside-macro (fun one two)
- (macro-result ((op fun)
- (arg1 one)
- (arg2 two))
- (format t "~A <- (~A ~A ~A)~&" (funcall op arg1 arg2) op arg1 arg2)))
- (defmacro macro-caller ()
- (generate-code-inside-macro #'+ 1 2))
Advertisement
Add Comment
Please, Sign In to add comment