[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding the same variable twice in a single form



    Date: Thu, 12 Apr 90 13:33 CDT
    From: lgm@ihlpf.att.com

    Let's say I have a function FUNC that returns three values.  In a
    particular situation I need only the third value.  On the
    Symbolics I could write

	    (MULTIPLE-VALUE-BIND (IGNORE IGNORE X) (FUNC)
		    <use X somehow>)

    The question is whether this usage is portable.  Other Common Lisp
    implementations may treat IGNORE as an ordinary variable name, and
    thereby interpret the expression as binding the same variable
    twice in the same form.  The Symbolics allows this silently in any
    case, even an obvious one like

	    (LET ((A 3) (A 4)) A)

    But do other CL implementations act similarly?  Does the upcoming
    ANSI standard address this question?


It is pretty assuredly not portable.  It is commonly necessary to do:

 (multiple-value-bind  (ignore1 ignore2 foo)
   (declare (ignore ignore1 ignore2))
   ...)

Most implementations will complain that IGNORE (or A, in the other
example) is not used, meaning the lexically shadowed one.


Eric C. Weaver
&Assocs., Inc.