[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Name That Class



    Date: 28 Jul 87 19:21 PDT
    From: Gregor.pa@Xerox.COM

    It seems to me that there are ways for class-named and setf of such to
    work.  I think only two of these are reasonable, but I will include the
    third for completeness.  Note that this same analysis applies to
    generic-function-name and setf of symbol-function and
    get-setf-generic-function.  I will do class names first.

    A class C 'is bound to' a given name Ni iff (class-named Ni) returns C.

    In all this solutions, we document class-named and setf of class-named.
    We say that class-named returns the class is bound to a particular name.
    We say that setf of class-named can be used to set the binding of a
    class to a name.

All agreed, except I think we decided a month ago to rename class-named to
symbol-class, to be more consistent with the rest of Common-Lisp.

    Solution 1:
      Only document class-named and setf of class-named.  Most
    implementations will have some magic for printing out a class's name
    when it has one.

    Solution 2:
      Document class-named and setf of class-named.  Also document
    class-name, but say that the the class may or may not 'bound' to that
    name.

    Solution 3:
      Document class-named and class-names and setf of class-named.  Say
    that setf of class-named can be used to bind a clas to a name.  Say that
    class-names returns the list of all names that a class is bound to.

    It seems to me that solution 1 and solution 3 are the only reasonable
    ones.  My general dislike of names makes me prefer solution 1, but I
    think that solution 3 actually provides users some important
    functionality.

That's interesting, because I prefer solution 2, for the simple reason
that everything else I can think of that has a name works that way.  The
symbol->object mapping is the "real" one, and the object->symbol mapping
is only a helpful hint for printing things out, but isn't necessarily kept
consistent with the symbol->object (a programming environment might try
to keep it consistent).

As far as I am concerned, any of these three would work.  My objection
to solution 3 is primarily that it is more complicated.  My objection to
solution 1 is that it is the same as solution 2 as soon as the users
discover what the name of the class-name function is, and no useful
purpose is served by making this name implementation-dependent.

    ....
    (setf (class-named 'n1) nil)
    #<Standard-Class N2 1>

Is this really how we want to undo these bindings?  Nothing else in Common
Lisp I can think of works this way (storing nil).  Also, a minor nit, CL
requires that such a setf form return nil, not the former value.

    I think its easy to see how this whole thing would work for
    generic-function-name, symbol-function, setf of symbol-function,
    get-setf-generic-function and setf of get-setf-generic-function.

Agreed.  Note that (setf (symbol-function 'foo) nil) isn't how we do
(fmakunbound 'foo) in CL currently.