[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CLOS accessors & declarations

A quick question that has me a bit perplexed.  In CLOS you let 
the evaluator know what type of object you are dealing with by
using methods, i.e.

(defclass TObj ()
  ((fSlot :accessor my-accessor)))

(defmethod Do-Something ((anObj TObj))
  (my-accessor anObj))

this lets the evaluator know that my-accessor should be tied to
anObj of type TObj.

The problem I am having is when I have a list of objects, I
can't figure out how to tell the evaluator that this list only
contains objects of type TObj, for example:

(doloop (anObj list-of-TObj)
        (print (my-accessor anObj)))

Adding a simple declaration to the loop does not seem to work:

(doloop (anObj list-of-TObj)
        (declare (type TObj anObj))
        (print (my-accessor anObj)))

Any idea of the proper way to do this so the evaluator doesn't
yip at me when I evaluate the above construct?