From: ogliomus
Subject: defmethod print-object
Date: 
Message-ID: <vbp1p15d8sucacekoqltm4ng600sadj3mp@4ax.com>
Probably another silly question:

(defmethod clos:print-object ((obj (eql 'jack)) stream)
  (princ 'J stream))

The example is taken from Shapiro's book Common Lisp An Interactive
Approach. Why is this working in Allegro CL, but not in Clisp and
Lispworks where 'jack returns JACK and not J as espected. But it works
if I type (print-object 'jack).
GC

From: drewc
Subject: Re: defmethod print-object
Date: 
Message-ID: <r_7kf.22747$Eq5.2206@pd7tw1no>
ogliomus wrote:
> Probably another silly question:
> 
> (defmethod clos:print-object ((obj (eql 'jack)) stream)
>   (princ 'J stream))
> 
> The example is taken from Shapiro's book Common Lisp An Interactive
> Approach. Why is this working in Allegro CL, but not in Clisp and
> Lispworks where 'jack returns JACK and not J as espected. But it works
> if I type (print-object 'jack).
> GC

I'm going to guess that it's because the other implementations don't put 
PRINT-OBJECT in a package called "CLOS". (i don't have clisp or 
lispworks at hand).

Try removing the package prefix and see how far that gets you.

-- 
Drew Crampsie
drewc at tech dot coop
  "... the most advanced use of lisp in the field of bass lure sales"
	-- Xach on #lisp
From: ogliomus
Subject: Re: defmethod print-object
Date: 
Message-ID: <6a43p113oijqc5mupfp816d5hr8kvrt603@4ax.com>
drewc <·····@rift.com> wrote:
>>[...]
>I'm going to guess that it's because the other implementations don't put 
>PRINT-OBJECT in a package called "CLOS". (i don't have clisp or 
>lispworks at hand).
>
>Try removing the package prefix and see how far that gets you.

No, removing the package prefix doesn't change the result.
GC
From: Pascal Costanza
Subject: Re: defmethod print-object
Date: 
Message-ID: <3vd7ckF14vqgqU1@individual.net>
ogliomus wrote:
> Probably another silly question:
> 
> (defmethod clos:print-object ((obj (eql 'jack)) stream)
>   (princ 'J stream))
> 
> The example is taken from Shapiro's book Common Lisp An Interactive
> Approach. Why is this working in Allegro CL, but not in Clisp and
> Lispworks where 'jack returns JACK and not J as espected. But it works
> if I type (print-object 'jack).

ANSI Common Lisp specifies that you should not define such a method. 
There are two sections in the specification that are relevant here:

- Section 11.1.2.1.2 Constraints on COMMON-LISP Package for Conforming 
Programs.

Bullet 19: [The consequences are undefined if you define] a method for a 
standardized generic function which is applicable when all of the 
arguments are direct instances of standardized classes.

PRINT-OBJECT is a standardized generic function, SYMBOL is a 
standardized class, and your method would be applicable for 'jack which 
is a direct instance of SYMBOL, so this rule applies.

- In the specification for PRINT-OBJECT, it is stated that users "may 
write methods for print-object for their own classes if they do not wish 
to inherit an implementation-dependent method." SYMBOL is not your own 
class.


Pascal

-- 
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
From: ogliomus
Subject: Re: defmethod print-object
Date: 
Message-ID: <ph43p15d74a98v6270jm79c79p5nf27roc@4ax.com>
Pascal Costanza <··@p-cos.net> wrote:
>>[...]
>ANSI Common Lisp specifies that you should not define such a method. 
>There are two sections in the specification that are relevant here:
>[...]
>- In the specification for PRINT-OBJECT, it is stated that users "may 
>write methods for print-object for their own classes if they do not wish 
>to inherit an implementation-dependent method." SYMBOL is not your own 
>class.

Ok, this sounds reasonable.
GC