MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Symbols, names, objects: kludge

  • To: mathgroup at
  • Subject: [mg6517] Symbols, names, objects: kludge
  • From: murray at (Murray Eisenberg)
  • Date: Thu, 27 Mar 1997 02:43:44 -0500 (EST)
  • Organization: University of Massachusetts, Amherst
  • Sender: owner-wri-mathgroup at

In an earlier posting, I asked how to define a function
store[varname_String, dataname_String] that causes a variable to be
created whose name is given by the string used as first argument and
which assigns as the value of that new variable the value of the
object whose name is given by the string used as the second argument.
For example,

   x = 99;
   store["myx", "x"]

should mean that an input


now produces


as output.

I found one method that works -- sort of, and sometimes -- but which I
don't fully understand:

   store[varname_String, dataname_String] :=

Unfortunately, I need to use such a function store inside a Module,
like this:

   wrapper[shortname_String] := Module[{temp},
      temp = ...... (* value created here *) ;
      store["new"<>shortname, "temp"];

and now, because temp is a local variable in the Module, the whole
thing breaks down (assigning the SYMBOL temp as the value of the
new... variable).

A real kludge is:

   wrapperkludged[shortname_String] := 
      (temp = ...... ;
       store["new"<>shortname, "temp"];

but clearly that is most unpleasant (since, in my actual application,
there are a whole bunch of local variables in the Module that calls
the function store.

So I'm still seeking a satisfactory solution!

  Murray Eisenberg                       Internet:  murray at
  Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
  University of Massachusetts                       413-549-1020 (H)
  Amherst, MA 01003                           Fax:  413-545-1801

  • Prev by Date: Symbols, names, objects
  • Next by Date: Fourier Transforms and Integers
  • Previous by thread: Re: Symbols, names, objects
  • Next by thread: Re: Symbols, names, objects: kludge