From: Andy Chambers
Subject: CLOS and dynamic variables
Date: 
Message-ID: <d7f6db03-fcdc-4534-9add-4c8e4f7a0299@41g2000hsh.googlegroups.com>
Does CLOS do something weird with dynamic variables?

If I do the following...

(defclass a ()
  ())

(defmethod print-object ((a a) stream)
  (print *print-pretty* stream))

....then evaluate

(let ((*print-pretty* nil))
       (make-instance 'a))

T is printed.

How does that work?

From: petere
Subject: Re: CLOS and dynamic variables
Date: 
Message-ID: <d507aeff-5e22-4a42-89ee-b8bf1b614f83@o6g2000hsd.googlegroups.com>
On Nov 16, 12:52 pm, Andy Chambers <··············@googlemail.com>
wrote:
> Does CLOS do something weird with dynamic variables?
>
> If I do the following...
>
> (defclass a ()
>   ())
>
> (defmethod print-object ((a a) stream)
>   (print *print-pretty* stream))
>
> ....then evaluate
>
> (let ((*print-pretty* nil))
>        (make-instance 'a))
>
> T is printed.
>
> How does that work?

Because (print-object) isn't called within the let, it's called to
print result of evaluating the entire expression. At that time, *print-
pretty* is back to its default of T. Nothing to do with CLOS.

- Peter
From: Alan Crowe
Subject: Re: CLOS and dynamic variables
Date: 
Message-ID: <86y7cy5afe.fsf@cawtech.freeserve.co.uk>
Andy Chambers <··············@googlemail.com> writes:

> Does CLOS do something weird with dynamic variables?
> 
> If I do the following...
> 
> (defclass a ()
>   ())
> 
> (defmethod print-object ((a a) stream)
>   (print *print-pretty* stream))
> 
> ....then evaluate
> 
> (let ((*print-pretty* nil))
>        (make-instance 'a))
> 
> T is printed.
> 
> How does that work?

You are seeing the REPL print the value returned by the LET form,
which is necessarily outside of the extent of the LET form

CL-USER> (let ((*print-pretty* nil))
       (make-instance 'a))

T 

If you stick in an explicit print, you force a call to
print-object with-in the extent of the let.

CL-USER> (let ((*print-pretty* nil))
           (print (make-instance 'a)))


NIL  


T 

Alan Crowe
Edinburgh 
Scotland
From: Rainer Joswig
Subject: Re: CLOS and dynamic variables
Date: 
Message-ID: <joswig-3A2E15.19190816112007@news-europe.giganews.com>
In article 
<····································@41g2000hsh.googlegroups.com>,
 Andy Chambers <··············@googlemail.com> wrote:

> Does CLOS do something weird with dynamic variables?
> 
> If I do the following...
> 
> (defclass a ()
>   ())
> 
> (defmethod print-object ((a a) stream)
>   (print *print-pretty* stream))
> 
> ....then evaluate
> 
> (let ((*print-pretty* nil))
>        (make-instance 'a))
> 
> T is printed.
> 
> How does that work?

Typical question: which Lisp are you using?
ACL?
From: Rainer Joswig
Subject: Re: CLOS and dynamic variables
Date: 
Message-ID: <joswig-80F883.19544316112007@news-europe.giganews.com>
In article <····························@news-europe.giganews.com>,
 Rainer Joswig <······@lisp.de> wrote:

> In article 
> <····································@41g2000hsh.googlegroups.com>,
>  Andy Chambers <··············@googlemail.com> wrote:
> 
> > Does CLOS do something weird with dynamic variables?
> > 
> > If I do the following...
> > 
> > (defclass a ()
> >   ())
> > 
> > (defmethod print-object ((a a) stream)
> >   (print *print-pretty* stream))
> > 
> > ....then evaluate
> > 
> > (let ((*print-pretty* nil))
> >        (make-instance 'a))
> > 
> > T is printed.
> > 
> > How does that work?
> 
> Typical question: which Lisp are you using?
> ACL?

Ignore.

I was thinking of something else. Some Implementations have
different variables in the REPL.