From: Peter Seibel
Subject: Methods generated by DEFCLASS
Date: 
Message-ID: <m3y8mxwpls.fsf@javamonkey.com>
I assume I'm just, once again, looking in the wrong place or blanking
out as my eyes pass over the right words but I can't find where in the
standard it specifies how the methods generated by DEFCLASS for
:reader, :writer, and :accessor functions are specialized. I'd assume
for each DEFCLASS a method would be created that specializes the
appropriate argument on that class. But such methods would also work
if the object argument was specialized on STANDARD-OBJECT. Most of the
time it wouldn't matter but I think you could detect the difference by
defining the GF and then defining methods on the GF before or after
evaluating the DEFCLASS. So is it specified somewhere that I'm
overlooking?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp

From: Pascal Costanza
Subject: Re: Methods generated by DEFCLASS
Date: 
Message-ID: <ca6bou$k5k$1@newsreader2.netcologne.de>
Peter Seibel wrote:

> I assume I'm just, once again, looking in the wrong place or blanking
> out as my eyes pass over the right words but I can't find where in the
> standard it specifies how the methods generated by DEFCLASS for
> :reader, :writer, and :accessor functions are specialized. I'd assume
> for each DEFCLASS a method would be created that specializes the
> appropriate argument on that class. But such methods would also work
> if the object argument was specialized on STANDARD-OBJECT.

No, because implicit methods for the same accessor gfs can be defined in 
many, possibly unrelated classes.

> Most of the
> time it wouldn't matter but I think you could detect the difference by
> defining the GF and then defining methods on the GF before or after
> evaluating the DEFCLASS. So is it specified somewhere that I'm
> overlooking?

Maybe this can be deduced from the last two paragraphs of 7.5.3? (Maybe 
it was part of the original MOP specification and got dumped?)


Pascal

-- 
1st European Lisp and Scheme Workshop
June 13 - Oslo, Norway - co-located with ECOOP 2004
http://www.cs.uni-bonn.de/~costanza/lisp-ecoop/
From: Joe Marshall
Subject: Re: Methods generated by DEFCLASS
Date: 
Message-ID: <4qpkwy7j.fsf@ccs.neu.edu>
Peter Seibel <·····@javamonkey.com> writes:

> I assume I'm just, once again, looking in the wrong place or blanking
> out as my eyes pass over the right words but I can't find where in the
> standard it specifies how the methods generated by DEFCLASS for
> :reader, :writer, and :accessor functions are specialized. I'd assume
> for each DEFCLASS a method would be created that specializes the
> appropriate argument on that class. But such methods would also work
> if the object argument was specialized on STANDARD-OBJECT. 

Huh?  If I write this:

(defclass foo (bar)
  ((x :initform :x :reader get-x)))

It is exactly the same as if I had written this:

(defclass foo (bar)
  ((x :initform :x)))

(defmethod get-x ((object bar)) 
   (slot-value bar 'x))

The get-x method defined here is not applicable to STANDARD-OBJECT
instances. 
From: Peter Seibel
Subject: Re: Methods generated by DEFCLASS
Date: 
Message-ID: <m3lliwvgxv.fsf@javamonkey.com>
Joe Marshall <···@ccs.neu.edu> writes:

> Peter Seibel <·····@javamonkey.com> writes:
>
>> I assume I'm just, once again, looking in the wrong place or blanking
>> out as my eyes pass over the right words but I can't find where in the
>> standard it specifies how the methods generated by DEFCLASS for
>> :reader, :writer, and :accessor functions are specialized. I'd assume
>> for each DEFCLASS a method would be created that specializes the
>> appropriate argument on that class. But such methods would also work
>> if the object argument was specialized on STANDARD-OBJECT. 
>
> Huh?  If I write this:
>
> (defclass foo (bar)
>   ((x :initform :x :reader get-x)))
>
> It is exactly the same as if I had written this:
>
> (defclass foo (bar)
>   ((x :initform :x)))
>
> (defmethod get-x ((object bar)) 
>    (slot-value bar 'x))

So you say. And I agree, insofar as that's what I'd expect. But
consider if you had written the method as:

  (defmethod get-x ((object standard-object))
    (slot-value bar 'x))

When called on instances of BAR, GET-X would work exactly the same way
in either case. There are obviously other consequences such as whether
calling GET-X on some other class that extends STANDARD-OBJECT signals
an error because there is no applicable method or because there is no
such slot. And, as I observed in my original post, you could detect
the difference by defining your own method by hand either before or
after you evaluate the DEFCLASS.

But I can't find anywhere in the standard that requires one
implementation or the other. Maybe it's one of those things that is
just so obvious that it wasn't considered necessary to specify it.
Which is fine. But if it is specified somewhere I'd be interested to
know where.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Barry Margolin
Subject: Re: Methods generated by DEFCLASS
Date: 
Message-ID: <barmar-B2317A.13310309062004@comcast.dca.giganews.com>
In article <··············@javamonkey.com>,
 Peter Seibel <·····@javamonkey.com> wrote:

> But I can't find anywhere in the standard that requires one
> implementation or the other. Maybe it's one of those things that is
> just so obvious that it wasn't considered necessary to specify it.
> Which is fine. But if it is specified somewhere I'd be interested to
> know where.

The dictionary entry for DEFCLASS says that no reader or writer methods 
are defined automatically unless you request them explicitly with 
:READER, :WRITER, or :ACCESSOR.  It doesn't seem to make much sense that 
some other, unrelated class definition would affect this, which implies 
that they must be specialized to the current class.

However, it would probably have been a good idea to say this explicitly.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Joe Marshall
Subject: Re: Methods generated by DEFCLASS
Date: 
Message-ID: <u0xkvd8g.fsf@ccs.neu.edu>
Peter Seibel <·····@javamonkey.com> writes:

> Joe Marshall <···@ccs.neu.edu> writes:
>>
>> (defclass foo (bar)
>>   ((x :initform :x :reader get-x)))
>>
>> It is exactly the same as if I had written this:
>>
>> (defclass foo (bar)
>>   ((x :initform :x)))
>>
>> (defmethod get-x ((object bar)) 
>>    (slot-value bar 'x))

ARGHHHH!!!  I said that wrong.

 (defmethod get-x ((object FOO)) 
    (slot-value object 'x))

Is what I meant.

> So you say. And I agree, insofar as that's what I'd expect. But
> consider if you had written the method as:
>
>   (defmethod get-x ((object standard-object))
>     (slot-value bar 'x))
>
> When called on instances of BAR, GET-X would work exactly the same way
> in either case. 

Yes, but it fails in this case:

(defclass foo (bar)
  ((foobar :initform :x :reader get-x)))

(defclass baz (bar)
  ((x :initform :x :reader get-x)))


Unless the methods were specialized for the most specific class, the
definition of BAZ would cause FOO to break.
From: Peter Seibel
Subject: Re: Methods generated by DEFCLASS
Date: 
Message-ID: <m3y8mwtx2b.fsf@javamonkey.com>
Joe Marshall <···@ccs.neu.edu> writes:

> Yes, but it fails in this case:
>
> (defclass foo (bar)
>   ((foobar :initform :x :reader get-x)))
>
> (defclass baz (bar)
>   ((x :initform :x :reader get-x)))
>
>
> Unless the methods were specialized for the most specific class, the
> definition of BAZ would cause FOO to break.

Good point. That's enough for me. Thanks. Thanks also to Barry who
made a similar point elewhere in this thread.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp