with-slots and multiple-value-bind 
Author Message
 with-slots and multiple-value-bind

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))



Mon, 29 Dec 1997 03:00:00 GMT  
 with-slots and multiple-value-bind

 > 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)))   )

--



Mon, 29 Dec 1997 03:00:00 GMT  
 with-slots and multiple-value-bind

Quote:
>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

Phone (617) 873-3126 - Fax (617) 873-5124



Mon, 29 Dec 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Final SRFI 8: RECEIVE: Binding to multiple values

2. SRFI 8: RECEIVE: Binding to multiple values

3. Defining multiple-values binding forms

4. MULTIPLE-VALUE-BIND question

5. multiple-value binding let and let*

6. binding multiple values (Ex: Re: some small proposed changes to standard)

7. lambda list in MULTIPLE-VALUE-BIND?

8. Common Lisp summary and multiple value binding

9. let vs. multiple-value-bind

10. multiple-value-bind

11. (let (flet (multiple-value-bind (etc.))))

12. (values (multiple-value-form)) whats the point?

 

 
Powered by phpBB® Forum Software