Hi there,
Let's say that I get from the user a list of atoms as an argument
and I want each one of them to become global known as an symbol/variable
in my program. Something like this :
(call2func '(a b))
and I want to have a and b as global variable that I can assign values
to them.
Thanks,
From: Tim Bradshaw
Subject: Re: How to declare a global varialbe
Date:
Message-ID: <ey3yab623jr.fsf@cley.com>
* Shy Shyman wrote:
> and I want to have a and b as global variable that I can assign values
> to them.
Are you sure this is what you want to do? If you want the names A and
B to be available as repositories of information you might be better
off storing them in a hashtable or something:
(defvar *tab* (make-hash-table))
(defun get-var (name)
(gethash name *tab*))
(defun (setf get-var) (new name)
(setf (gethash name *tab*) new))
(defun register-variables (varnames)
(dolist (var varnames varnames)
(setf (getvar name) nil)))
Or something like that?
--tim
In article <··········@news.or.intel.com>,
Shy Shyman <··········@intel.com> wrote:
>Hi there,
>
>Let's say that I get from the user a list of atoms as an argument
>and I want each one of them to become global known as an symbol/variable
>in my program. Something like this :
>(call2func '(a b))
>
>and I want to have a and b as global variable that I can assign values
>to them.
If you *really* want to do this, you can do:
(defun call2func (varlist)
(proclaim `(special ,@varlist)))
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.