Saturday, August 23, 2008

defclass options slay me, again

I previously wrote about missing canonicalize-defclass-options. Now I have a nice inconsistency in AMOP to add to the complaints.

I have believed for some time, for some reason, that this is the standard slot option canonicalizer, excepting the special cases:

(defun canonicalize-defclass-option (opt)
`(',(car opt)
',(if (typep (cdr opt) '(cons t null))
(cadr opt)
(cdr opt))))
In other words, if you gave a single argument, like (:opt val), it wouldn't be listified. A little weird, with a nasty special case, but a good attempt at dealing with both listy and atomy class options.

Thankfully, AMOP has two contradictory interpretations, neither of which are the above. First, the example on page 287, which would have it:

  `(',(car opt)
',(cadr opt))
Finally, on page 148, hiding from the prying eyes of back-of-the-book indexed content (nowhere near the entries on defclass), the true behavior:
Any other class options become the value of keyword arguments with the same name. The value of the keyword argument is the tail of the class option.
  `(',(car opt)
',(cdr opt))
I also previously thought the defclass options to be evaluated, but never mind that.

No comments: