[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 17:41 EDT
   From: barmar@Think.COM (Barry Margolin)
  
   ...

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

	   (MULTIPLE-VALUE-BIND (VAL1 VAL2 X) (FUNC)
	     (DECLARE (IGNORE VAL1 VAL2))
	     <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.

						   barmar

Devils' advocate: How about the following (obviously kludgy) example?

(let* ((operation (get-operation))
       (operation (if (null operation)
                      (get-emergency-operation)
                      operation))
       (status (if operation :safe :panic)))
   ... code that uses operation and status variables ...)

for example:

(defun get-a-number ()
  (let* ((number (read))
         (number (if (numberp number) number 0)))
     (print number)))

It may not be nice programming style, but it works...

--- The Traveller -->|<-