[Openmcl-devel] Problem with non-standard class options in defclass expansion

Gary Byers gb at clozure.com
Wed Mar 24 13:12:22 PST 2004



On Wed, 24 Mar 2004, Gary King wrote:

> The defclass macro is taking only the car of non-standard defclass
> options instead of the entire option. To point out a particular case,
> here is the example from
> http://www.lisp.org/mop/concepts.html#defclass. The macro-expansion of:
>
> (defclass sst (plane)
>       ((mach mag-step 2
>              locator sst-mach
>              locator mach-location
>              :reader mach-speed
>              :reader mach))
>    (:metaclass faster-class)
>    (another-option foo bar))
>
> Gives
>
> (ccl::ensure-class-for-defclass
>   'sst
>   :direct-superclasses
>   '(plane)
>   :direct-slots
>   (list (list :name 'mach :readers '(mach mach-speed)
>               'mag-step '2 'locator 'sst-mach 'locator
>               'mach-location))
>   :metaclass (find-class 'faster-class)
>   'another-option 'foo)
>
> rather than:
>
> (ensure-class 'sst
>    ':direct-superclasses '(plane)
>    ':direct-slots (list (list ':name 'mach
>                               ':readers '(mach-speed mach)
>                               'mag-step '2
>                               'locator '(sst-mach mach-location)))
>    ':metaclass 'faster-class
>    'another-option '(foo bar))
>
> If I read things correctly, the offending line is the last one in the
> option parsing section of defclass:
>
>   (case option-name
>                     (:default-initargs
>                         (let ((canonical ()))
>                           (let (key val (tail (cdr option)))
>                             (loop (when (null tail) (return nil))
> 			       (setq key (pop tail)
> 				     val (pop tail))
> 			     (push ``(,',key ,,(make-initfunction val) ,',val) canonical))
>                             `(':direct-default-initargs (list
> ,@(nreverse canonical))))))
>                     (:metaclass
>                      (unless (and (cadr option)
>                                   (typep (cadr option) 'symbol))
>                        (illegal-option option))
>                      `(:metaclass (find-class ',(cadr option))))
>                     (t
>                      (list `',option-name `',(cadr option))))))
>
> I think that it should be (list `',option-name `',(cdr option))
>
> Looking for enlightenment,
> --
> Gary Warren King, Lab Manager
> EKSL East, University of Massachusetts * 413 577 0176
>

It was changed from (CDR OPTION) to (CADR OPTION) sometime between
last October and last December;  I don't remember why this change
was made, but I agree that the MOP spec implies that (CDR OPTION)
is correct.

<http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lib/macros.lisp.diff?r1=1.1&r2=1.2>



More information about the Openmcl-devel mailing list