From: Rand Sobriquet
Subject: Evaluating a list programmatically
Date: 
Message-ID: <1e249696.0405310723.63e0c2b2@posting.google.com>
I have this class:

(defclass example ()
  ((worksheet-font
    :accessor worksheet-font
    :initform (gp:make-font-description 
               :family "Verdana" :size 12 :weight :normal :slant :roman)
    :initarg :worksheet-font
    :documentation "The worksheet'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 worksheet-font varies, but I
would like it to be reset to its default initform value occasionally.

A call such as (default-state 'example 'worksheet-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 'worksheet-font))))
  ....)

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

(let* ((default-initform (default-state 'example 'worksheet-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)

From: Kalle Olavi Niemitalo
Subject: Re: Evaluating a list programmatically
Date: 
Message-ID: <877jusqyr6.fsf@Astalo.kon.iki.fi>
··········@eudoramail.com (Rand Sobriquet) writes:

> (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))))

Use SLOT-DEFINITION-INITFUNCTION instead, and FUNCALL the result.
Trying to EVAL the initform fails in cases like this:

  (let ((x 'hello))
    (defclass foo ()
      ((zoom :initform x))))
From: Rahul Jain
Subject: Re: Evaluating a list programmatically
Date: 
Message-ID: <87d64io3i8.fsf@nyct.net>
Kalle Olavi Niemitalo <···@iki.fi> writes:

> Use SLOT-DEFINITION-INITFUNCTION instead, and FUNCALL the result.
> Trying to EVAL the initform fails in cases like this:

To be clear, SLOT-DEFINITION-INITFORM is _only_ for visual display of
the initform. The initfunction is the thing that _actually_ defines the
initializer for the slot.

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist