[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

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

The draft I have (dated June 20, 1989) doesn't specifically mention the
consequences of specifying a variable twice in the same
MULTIPLE-VALUE-BIND or LET form.  Were we to specify it, I expect we
would say that "the consequences are unspecified", which means that the
standard doesn't proscribe a particular behavior but it can't cause a
fatal error.  I doubt if any implementation would violate this.  If you
don't use the duplicated variable then you shouldn't have a problem.

In the case of IGNORE variables, the portable way to do this is with the
IGNORE declaration:

	  <use X somehow>)

I can't think of any other reason why you would want to bind the same
variable twice in the same form, so the larger question should be moot.