On Mon, Dec 27, 2010 at 10:55 AM, Leslie P. Polzer
<[email protected]> wrote:
> On Dec 27, 3:40 am, "Scott L. Burson" <[email protected]> wrote:
>> CLASS-ID-SLOT-NAME seems infelicitous.
>
> Thanks for using this word. :]
>
>> To define a method on it you
>> have to say something like
>>    (defmethod class-id-slot-name ((class (eql (find-class 'user))))
>>     'name)
>>
>> and then you don't automatically get the benefit of inheritance.
>>
>> Seems like the natural thing would be to define methods on OBJECT-ID-
>> SLOT-NAME... but it's not generic!
>>
>> Am I missing something here?
>
> We should keep class-id-slot-name for backwards
> compatibility and convert object-id-slot-name to a GF. Feel free to
> submit a patch for this.

As it turns out, I _was_ missing something.
FIND-PERSISTENT-OBJECT-BY-ID (at least, the method for the CLSQL
store) calls CLASS-ID-SLOT-NAME directly, because it doesn't have an
instance handy.  So, it has to work.  There's a bug, though;
CLASS-ID-SLOT-NAME should be getting passed a symbol, but
OBJECT-ID-SLOT-NAME is passing it a class object (that's why, in the
above example, it's specialized on the class object; I hadn't yet
noticed the inconsistency).  So OBJECT-ID-SLOT-NAME should be changed
to call CLASS-NAME:

(defun object-id-slot-name (obj)
  "Returns the slot name of the slot that holds the unique identifier
of 'obj'. This information is obtained via calling
'class-id-slot-name'."
  (class-id-slot-name (class-name (class-of obj))))

and then the user-defined methods on CLASS-ID-SLOT-NAME can specialize
on symbols:

  (defmethod class-id-slot-name ((class (eql 'user)))
    'name)

The alternative, I suppose, would be to flip things around and make
CLASS-ID-SLOT-NAME actually MAKE-INSTANCE the class, then call
OBJECT-ID-SLOT-NAME on the instance.  But I don't like the idea of
creating an instance just for this purpose.

It would also be possible to implement inheritance explicitly, but I
don't think it's worth the trouble for this.

-- Scott

-- 
You received this message because you are subscribed to the Google Groups 
"weblocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/weblocks?hl=en.

Reply via email to