;;AUTOLOAD: defaccessor
;;AUTODOC: defaccessor "Create an accessor to a class slot"
"defaccessor - Create an accessor to a class slot
(defaccessor name class slot )

Creates a function named name, which can be used to access the 
value of the slot on objects of class. This function will be called 
with one argument (the object) to fetch the value, and with two 
(the object and the new value) to store a new value.

We recommend to prefix the accessor name with the class name. For 
example, an accessor for the slot slotName of class MyClass, would 
be named myClass.slotName.

(defaccessor Point.x Point 'x)
(defaccessor Point.y Point 'y)
(Point.x myPoint 3)				 3
(Point.x myPoint)				 3
(Point.y myPoint 7)				 7
(Point.y myPoint)				 7
myPoint				   {Point x 3 y 7}

Note: Accessors are not redefinable by the system methods get and 
put, so they must can used for the implementation of these system 
methods.
"

(defunq defaccessor (defaccessor:name defaccessor:class defaccessor:slot)
  (set defaccessor:name
    (eval `(lambda (obj &optional (value :nil))
	(if (= value :nil)
	  (*:slot obj
	    ,(*:slot-offset (eval defaccessor:class)
	      (eval defaccessor:slot))
	  )
	  (*:slot obj
	    ,(*:slot-offset (eval defaccessor:class)
	      (eval defaccessor:slot))
	    value
))))))
	
