From: Karsten Poeck
Subject: with-slots and multiple-value-bind
Date: 
Message-ID: <poeck-1307951553290001@wi6a65.informatik.uni-wuerzburg.de>
the following peace of code gives a compiler warning and (1 2 3) as the
result in one of my favourite CLs and
(nil 2 3) in another.

Is it correct to assume that the reference introduced by multiple-value-bind
should shadow the with-slot binding?

Should I complain in Boston, Berkeley or blame the author of the code?

Karsten

(defclass bambi ()
  ((a :initform nil :accessor ba)
   ))


(defmethod a-bug? ((ich bambi))
  (with-slots (a)
              ich
    (multiple-value-bind 
      (a b c)
      (values 1 2 3)
      a
      (list a b c)))
  )

(a-bug? (make-instance  `bambi))

From: Thomas A. Russ
Subject: Re: with-slots and multiple-value-bind
Date: 
Message-ID: <TAR.95Jul13101753@hobbes.ISI.EDU>
In article <...> ·····@informatik.uni-wuerzburg.de (Karsten Poeck) writes:

 > the following peace of code gives a compiler warning and (1 2 3) as the
 > result in one of my favourite CLs and
 > (nil 2 3) in another.
 > 
 > Is it correct to assume that the reference introduced by multiple-value-bind
 > should shadow the with-slot binding?

From my reading of CLtL2, this would be correct.  It's a bit confusing
since the with-slot form is described in terms of the use of
symbol-macrolet, so I suspect that implementation #2 screwed up.

 > 
 > Should I complain in Boston, Berkeley or blame the author of the code?

Hmm.  I couldn't quite figure out who in Boston you would want to
complain to.  For me, the example works fine in both Macintosh Common
Lisp 2.0.1 and Allegro Common Lisp 4.2.   Although the forms are legal,
they are also confusing to human readers, so blaming the author is
justified.

 > Karsten
 > 
 > (defclass bambi ()
 >   ((a :initform nil :accessor ba)  ))
 > 
 > 
 > (defmethod a-bug? ((ich bambi))
 >   (with-slots (a)  ich
 >     (multiple-value-bind (a b c)
 >         (values 1 2 3)
 >         a
 >         (list a b c)))   )





--
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Barry Margolin
Subject: Re: with-slots and multiple-value-bind
Date: 
Message-ID: <3u3q4r$bo1@tools.near.net>
In article <······················@wi6a65.informatik.uni-wuerzburg.de> ·····@informatik.uni-wuerzburg.de (Karsten Poeck) writes:
>Is it correct to assume that the reference introduced by multiple-value-bind
>should shadow the with-slot binding?

Yes.  WITH-SLOTS is intended to be implemented using SYMBOL-MACROLET or
something equivalent.  The description of SYMBOL-MACROLET specifically says
that its bindings

    can therefore be shadowed by LET or other constructs that bind
    variables; SYMBOL-MACROLET does not substitute for all occurrences of a
    <var> as a variable but only for those occurrences that would be
    construed as references in the scope of a lexical binding of <var> as a
    variable.
-- 
Barry Margolin
BBN Planet Corporation, Cambridge, MA
······@bbnplanet.com
Phone (617) 873-3126 - Fax (617) 873-5124