title: Why aren't generic functions the same as accessor functions lisp
body: <p>From the things I have read I understand that Accessor functions in CLOS allows for the programmer to get and set variables and it generates a generic function of the name that was give in to the accessor to which you need to define different methods.But I what I want to know is why Don't generic functions work the same way as the accessor functions?</p>
  
  <p>for example</p>
  
  <pre><code> (defclass animal ()
         ((sound
           :initarg :sound
           :initform "no sound"
           :accessor make-sound)))
  </code></pre>
  
  <p>I can just 
  define</p>
  
  <pre><code>(defmethod (setf make-sound) ((the-animal animal) value)
         (setf (slot-value the-animal 'sound) value))
  </code></pre>
  
  <p>but if i were to take the accessor away and add in </p>
  
  <pre><code>(defgeneric (setf make-sound) (the-animal value))
  </code></pre>
  
  <p>then I get an error when after executing the following code.</p>
  
  <pre><code>(setf (make-sound dog) "bark")
  </code></pre>
  
  <p>unless I redefine the generic function and method as the following</p>
  
  <pre><code>(defgeneric (setf make-sound) (value the-animal))
  
   (defmethod (setf make-sound) (value (the-animal animal))
     (setf (slot-value the-animal 'sound) value))
  </code></pre>
  
  <p>or execute </p>
  
  <pre><code>(setf (make-sound "bark") dog) ;this also works with the accessor
  </code></pre>
  
  <p>My question is why is this happening?Why can't I achieve the same result with generic functions?</p>