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

Re: initializing class slots



    Date: 4 Feb 87 21:05 PST
    From: Danny Bobrow <Bobrow.pa@Xerox.COM>

	    (defclass A () ((s :initform 1 :allocation :class)))

	By the way, I could not find anything specific in the document
	that says how initforms work for class slots.  For example, exactly
	when is the initform evaluated?  At the time of the evaluating of
	the containing defclass?

    Yes and No.  It is no because it is really at the time the class is
    defined.  Compiling a file with a defclass will expand the defclass into
    something else, and that will evaluate at load time.  But for ordinary
    loading of files (or evaluating the form in a listener) the answer is
    yes.

Actually, I'd take that as a "yes" answer.  It's evaluated at the time
that the defclass is evaluated.  Compiling a file causes the defclass to
be evaluated when the file is loaded.  That is, defclass is (eval-when
(load eval) ...) by default, not (eval-when (compile load eval) ...).
So it's easy to explain.