[Openmcl-devel] Patch for slot documentation inflecity

Gary Byers gb at clozure.com
Wed Feb 1 07:48:22 PST 2006



On Wed, 1 Feb 2006, Gary King wrote:

> According to people who know the MOP much better than I do!, the
> following should work:
>

If I'd been asked - and hadn't been allowed to cheat - I'd have
said that DOCUMENTATION methods like those that you propose
already existed.  I would have been wrong, and I think that
specializing on SLOT-DEFINITION is more in the spirit of DOCUMENTATION
(and would make further specialization for subclasses of SLOT-DEFINITION
more straightforward.)


>> (in-package ccl)
>>
>> (defclass test ()
>>   ((a-slot :documentation "This is a test.")))
>>
>> (finalize-inheritance (find-class 'test))
>>
>> (assert (string= (documentation (find 'a-slot (class-slots (find-
>> class 'test))
>>                                       :key #'slot-definition-name)
>>                                 t)
>>                  "This is a test."))
>
> but it fails in OpenMCL (version 1.0).
>
> Either of these patches corrects this behavior in OpenMCL:
>
>>> (defmethod documentation ((slot slot-definition) (doc-type (eql 't)))
>>>   (slot-value slot 'documentation))
>>>
>>> (defmethod (setf documentation) ((new t)
>>> 				 (slot slot-definition)
>>> 				 (doc-type (eql 't)))
>>>   (setf (slot-value slot 'documentation) new))
>
> or
>
>>> (defmethod initialize-instance :after ((slot slot-definition) &key
>>> documentation)
>>>   (setf (documentation slot 't) documentation))
>
> I'm not sure which one is more legitimate so I'll let more informed
> minds make the choice!
>
> thanks,
> -- 
> Gary Warren King
> metabang.com
> http://www.metabang.com/
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list