lisp - How do I access a class object stored in an array? -


so if have defclass object , make instance of , place inside array. how value of slots inside array?

i've tried:

(slot-value (aref *array* 0) :name) 

i guess not understanding how access object inside array.

i can print object in unreadable form using (format t) there way print object , slots in form can understand?

(defun generate-object (name)   (let ((a (make-instance 'person                           :name name)))     (setf (aref *array* 0) a))) 

it places object inside array seems slot not being created?

this causes problem:

(defclass person ()   ((name :accessor name          :reader read-name          :initarg :name)))  (defvar *array* 0) (setf *array* (make-array 20))  (defun generate-object (name)   (let ((a (make-instance 'person                           :name name)))     (setf (aref *array* 0) a))) 

the slot name needs symbol syntactically valid variable name. try 'name instead of :name .

(slot-value (aref *array* 0) 'name) 

look @ examples here.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -