[cells-devel] Re: [cello-devel] Constructor syntax

Thomas F. Burdick tfb at OCF.Berkeley.EDU
Fri May 14 06:23:20 UTC 2004

Kenny Tilton writes:
 > Thomas F. Burdick wrote:
 > >So ... uh, which approach do you think is worse: using a
 > >c-slot-makunbound function that works for both normal and
 > >cell-mediated slots;
 > In this contrast between normal and cell-mediated, does normal mean a 
 > slot specified:
 >     :cell nil

I still need to work on my Cells-related terminology; I mean this
case.  That way Cells-using programs could use the same makunbound for
all objects, without worrying about where they came from.

 > [aside: is it c-slot-makunbound or md-slot-makunbound? I have both in re 
 > slot-value. md- takes the slot name, looks for a cell, calls c- if it 
 > finds one. By that parallel we are talkin bout md-slot-value]

Yeah, I guess it would be md-slot-makunbound, considering you get to
the slot with md-slot-value.

 > > or including hacks to make MCL and CLISP go
 > >through slot-makunbound-using-class?
 > Hunh? MCL does not /have/ a slot-makunbound-using-class (he guessed 
 > based on MCL not exposing much of the MOP). How can you make MCL go thru 
 > what it does not have? ie, if (i am guessing) slot-makunbound is a 
 > function, how do you change its behavior? advise (which is one corner of 
 > Lisp I have never visited)?
 > Golly I wish the MOP were part of the standard.

(No kidding).  Well, MCL doesn't /ship/ with s-m-u-c ... but it does
have enough of a MOP to write one.  Then, once such a beast is
written, slot-makunbound can be redefined to go through it.  In fact,
I have such a beast from my previous MCL adventures.  Those with
sensitive constitutions may want to skip this:

  (defpackage :s-m-u-c-patch
    (:use :common-lisp :ccl))
  (in-package :s-m-u-c-patch)
  (unless (fboundp 'ccl::slot-makunbound-using-class)
    (unless (fboundp '%slot-makunbound)
      (setf (symbol-function '%slot-makunbound)
            (symbol-function 'slot-makunbound)))
    (defgeneric ccl::slot-makunbound-using-class (class object slotd)
      (:method ((class standard-class) object (slotd cons))
               (%slot-makunbound object (slot-definition-name slotd))))
    (handler-bind ((error (lambda (e)
                            (let ((do-it (find-restart 'continue e)))
                              (when do-it (invoke-restart do-it))))))
      (defun slot-makunbound (object slot)
        (let* ((class (class-of object))
               (slotd (or (find slot (class-instance-slots class)
                                :key #'slot-definition-name)
                          (slot-missing class object slot 'slot-makunbound))))
          (ccl::slot-makunbound-using-class class object slotd))))
    (export '(ccl::slot-makunbound-using-class) :ccl))

But, uhm, it does work.  It's evil in a good way?

Personally, I'd go with slot-makunbound-using-class, and hack it into
systems missing it (obviously, since I load the above code in my MCL
init file).  But if you find that to be in bad taste, I could do the
md-slot-makunbound route.  *I* think I have great taste, but not
everyone always agrees; some people prefer to fake the funk.

More information about the cello-devel mailing list