Evaluating a list programmatically

From: Rand Sobriquet (rsobriquet_at_eudoramail.com)
Date: 05/31/04


Date: 31 May 2004 08:23:51 -0700

I have this class:

(defclass example ()
  ((work***-font
    :accessor work***-font
    :initform (gp:make-font-description
               :family "Verdana" :size 12 :weight :normal :slant :roman)
    :initarg :work***-font
    :documentation "The work***'s font." )))

and I also have this function:

(defun default-state (class-name slot-name)
  (loop :for slot-definition :in (class-slots (find-class class-name))
        :when (eql (slot-definition-name slot-definition) slot-name)
        :do (return (slot-definition-initform slot-definition))))
   
What happens is that the state of the work***-font varies, but I
would like it to be reset to its default initform value occasionally.

A call such as (default-state 'example 'work***-font) will return the
list (gp:make-font-description :family "Verdana" :size 12 :weight
:normal :slant :roman)

May I ask, how do you do use this result with style? At first I thought I should

(let ((default-font (eval (default-state 'example 'work***-font))))
  ....)

But then I thought that I had better remove eval. So then I'm using

(let* ((default-initform (default-state 'example 'work***-font))
       (default-font (apply (first default-initform) (rest default-initform))))

There's something about these two solutions that I dislike (I think
that they are too complicated), so how you do usually deal with a returned list
that must be evaluated? Thanks in advanced for answering this really silly question
for me but it's the simple stuff that leaves me confused.

Rand
(Please don't email me because I'm running a spam experiment)


Quantcast