
(defmacro define-global-setf-expander (accessor)
  (let ((getter-macro (intern
		       (format nil "~A-SETF-GETTER-MACRO" accessor)))
	(setter-macro (intern
		       (format nil "~A-SETF-SETTER-MACRO" accessor))))
    `(progn
       (defmacro ,setter-macro (obj val)
	 `(funcall #'(setf ,',accessor) ,obj ,val))
       (defmacro ,getter-macro (obj)
	 `(,',accessor ,obj))
       (define-setf-expander ,accessor (object)
	 (let ((store (gensym))
	       (targ (gensym)))
	   (values (list store)
		   (list object)
		   (list targ)
		   (list ',setter-macro targ store)
		   (list ',getter-macro targ)))))))

(defparameter *foo* '(0))

(defun foo-val (o)
  (car o))
(defun (setf foo-val) (v o)
  (setf (car o) v))
(define-global-setf-expander foo-val)

(defun test ()
  (setf (foo-val *foo*) 1))

