Advertisement
Guest User

Untitled

a guest
May 26th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. (defmacro define-accessor-alias (alias (&rest lambda-list) original)
  2. (let ((ll (parse-lambda-list lambda-list :ordinary)))
  3. `(progn
  4. (defun ,alias ,lambda-list (,original ,@(make-flat-argument-list ll)))
  5. (defun (setf ,alias) (new-value ,@lambda-list) (setf (,original ,@(make-flat-argument-list ll)) new-value)))))
  6.  
  7. (pprint (macroexpand-1 '(define-accessor-alias kar (cons) car)))
  8. --> (progn (defun kar (cons) (car cons)) (defun (setf kar) (new-value cons) (setf (car cons) new-value)))
  9.  
  10. (pprint (macroexpand-1 '(define-accessor-alias subsequence (sequence start &optional end) subseq)))
  11. --> (progn (defun subsequence (sequence start &optional end) (subseq sequence start end))
  12. (defun (setf subsequence) (new-value sequence start &optional end) (setf (subseq sequence start end) new-value)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement