avoiding redundancy in Generalized Reference

From: Frank Buss (fb_at_frank-buss.de)
Date: 10/08/04

Date: Fri, 8 Oct 2004 21:04:30 +0000 (UTC)

I have a function like this:

(defun maze-aref (maze x y) (elt (elt maze (1+ (* y 2))) (1+ (* x 2))))

now I can call it for retrieving a value:

(maze-aref maze 4 2)

but setf gives an error:

(setf (maze-aref maze 4 2) #\Space)

so I define the inversion:

(defun (setf maze-aref) (new-stone maze x y)
  (setf (elt (elt maze (1+ (* y 2))) (1+ (* x 2)))

now setf works. But how can I avoid the redundancy? Is there a macro or
something which builts the inversion automaticly for simple cases like

Frank Buß, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de