MathGroup Archive 1997

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

Search the Archive

Re: strings & expressions in Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg6258] Re: [mg6244] strings & expressions in Module
  • From: seanross at worldnet.att.net
  • Date: Mon, 3 Mar 1997 01:29:16 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Murray Eisenberg wrote:
> 
> Naively, I expect the following, when evaluated, to return result 99:
> 
> Module[{y},
>    y = 99;
>    Evaluate at ToExpression["y"]
> ]
> 
> But it doesn't; instead, it returns:
> 
> y
> 
> I suspect the problem is that, inside the Module, y is not really y
> but rather y$1 or some symbol of the kind.  How can I modify the
> string "y" so that, in fact, the result returned is the value 99
> stored into y?
> 
> (Yes, this likes a strange thing to do: assign a value to a symbol
> inside a Module and then try to refer to the symbol indirectly by a
> string giving its name.  There's a good reason I want to do this!)
> 
> --
>   Murray Eisenberg                       Internet:  murray at math.umass.edu
>   Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
>   University of Massachusetts                       413-549-1020 (H)
>   Amherst, MA 01003                           Fax:  413-545-1801


Whenever I use a module, I use Return statements.  Another point is that 
by using Module[{y},.....], you have declared y a protected variable.  
If you want to access the value of y outside the module, just leave it 
off the protected variable list.


  • Prev by Date: Re: Differential Equations system
  • Next by Date: Re: Information about non-symbol heads
  • Previous by thread: Fwd: strings & expressions in Module
  • Next by thread: plotting a 3D cloud of points