I am wondering if there is a way to initialize a slot through the
execution of a procedure. For example,
(define-class <foo> ()
((slot :accessor slot
:init-keyword :slot)))
Let's say I want to initialize slot with some data structure like a
list, but I want the object to take the list and turn it into a hash
table.
(make <foo> :slot '(some sort of a-list))
So when the object is initialized I want to run a routine on the list
which will then install a hash-table equivalent of the list.
What I have been doing is establishing a "data slot" and then using a
virtual slot to control access :
(define-class <foo> ()
((data-slot :accessor data-slot)
(slot :accessor slot
:init-keyword :slot
:allocation :virtual
:slot-getter (lambda (self) ...)
:slot-setter (lambda (self obj)
(if data-slot is not initialized
do some complicated intialization using obj
and set data-slot)))))
It seems to me that this is not the "right" way to do this. Any
suggestion on a better way ?
The approach I thought would be most elegant is if there is a keyword
just like :initform with an associated procedure which operates on the
object used to initialize the slot, the results of that procedure is
then stored in the slot.
Thanks
Brian
Received on Wed Mar 10 1999 - 23:38:27 CET
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST