As Ramarren said, having to bind multiple variables isn't a common occurance. What is the issue in context of the problem you are solving?
It sounds like you have a small list of random numbers and you want to label them, destructuring bind is probably the easiest way to do it. An array of numbers (or a list) might be better: you would write (elt vars 0) instead of var1. Using an array or list also lets you loop across all values easily.
If you really want to bind variables (and, ideally, the amount of variables is known) you could use let, multiple-value-bind, destructuring-bind, apply, progv or symbol-macros.
let
(defun use-quantities ()
(let ((q1 2)
(q2 4)
(q3 6)
(q4 8)
(q5 5)
(q6 3)
(q7 5))
(format t "~%q1: ~a~%q2: ~a~%q3: ~a~%q4: ~a~%q5: ~a~%q6: ~a~%q7: ~a"
q1 q2 q3 q4 q5 q6 q7)))
Multiple-value-bind
(defun quantities () (values 2 4 6 8 5 3 5))
(defun use-quantities ()
(multiple-value-bind (q1 q2 q3 q4 q5 q6 q7) (quantities)
(format t "~%q1: ~a~%q2: ~a~%q3: ~a~%q4: ~a~%q5: ~a~%q6: ~a~%q7: ~a"
q1 q2 q3 q4 q5 q6 q7)))
destructuring-bind
(defun quantities () (list 2 4 6 8 5 3 5))
(defun use-quantities ()
(destructuring-bind (q1 q2 q3 q4 q5 q6 q7) (quantities)
(format t "~%q1: ~a~%q2: ~a~%q3: ~a~%q4: ~a~%q5: ~a~%q6: ~a~%q7: ~a"
q1 q2 q3 q4 q5 q6 q7)))
Apply
(defun quantities () (list 2 4 6 8 5 3 5))
(defun use-quantities (q1 q2 q3 q4 q5 q6 q7)
(format t "~%q1: ~a~%q2: ~a~%q3: ~a~%q4: ~a~%q5: ~a~%q6: ~a~%q7: ~a"
q1 q2 q3 q4 q5 q6 q7))
(apply #'use-quantities (quantities))
progv
(defvar *q1*)
(defvar *q2*)
(defvar *q3*)
(defvar *q4*)
(defvar *q5*)
(defvar *q6*)
(defvar *q7*)
(defun quantities () (list 2 4 6 8 5 3 5))
(defun use-quantities ()
(progv '(*q1* *q2* *q3* *q4* *q5* *q6* *q7*) (quantities)
(format t "~%q1: ~a~%q2: ~a~%q3: ~a~%q4: ~a~%q5: ~a~%q6: ~a~%q7: ~a"
*q1* *q2* *q3* *q4* *q5* *q6* *q7*)))
symbol macros
(defun quantities () (list 2 4 6 8 5 3 5))
(define-symbol-macro q1 (elt randoms 0)) ;; q1 will expand into (elt randoms 0), thus
(define-symbol-macro q2 (elt randoms 1)) ;; it will get the local binding of 'randoms'
(define-symbol-macro q3 (elt randoms 2))
(define-symbol-macro q4 (elt randoms 3))
(define-symbol-macro q5 (elt randoms 4))
(define-symbol-macro q6 (elt randoms 5))
(define-symbol-macro q7 (elt randoms 6))
(defun use-quantities ()
(let ((randoms (quantities)))
(format t "~%q1: ~a~%q2: ~a~%q3: ~a~%q4: ~a~%q5: ~a~%q6: ~a~%q7: ~a"
q1 q2 q3 q4 q5 q6 q7)))
Need an online wiki database? My Lisp startup
http://www.formlis.com combines a wiki with forms and reports.