[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question: CLOS, :accessor, compiler warning
- Subject: Question: CLOS, :accessor, compiler warning
- From: cecil@camis.stanford.edu (Cecil Huang)
- Date: 17 May 1993 06:35:21 GMT
Hi all,
This question refers to the following example:
(defclass account ()
((name :initarg :name :reader name)
(balance :initarg :balance :initform 0.00 :accessor balance)
(interest-rate :allocation :class :initform .06
:reader interest-rate)))
Now my understanding is that :accessor creates methods that allow me
to read and write the value of the slot balance. I do this as follows:
(setf a1 (make-instance 'account :balance 5000.00
:name "Fred"))
(name a1) ;; returns "Fred", no problem
(balance a1) ;; returns 5000.0, no problem
(setf (balance a1) 2000.00) ;; I get a warning. How can I avoid this?
The warning message I get is this:
;Compiler warnings :
; Undeclared free variable A1, in an anonymous lambda form.
2000.0
?
QUESTION. What is going on, and how can I avoid the warning? It seems
from all of the references I'm using (book by Norvig and MCL Reference)
that the setf syntax above is legal.
Eternally thankful,
Cecil Huang
cecil@camis.stanford.edu