Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: nice Gotcha!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15028] Re: [mg15011] nice Gotcha!
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Wed, 9 Dec 1998 04:12:16 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

On Sat, Dec 5, 1998, Barthelet, Luc <lucb at ea.com> wrote:


C>Code similar to the following gave me trouble today. I thought it would
>be fun to share:
>
>Clear[x];
>test[] := Module[
>      {x},
>      
>      ToExpression["x=3"];
>      Print[x];
>      ];
>test[];
>Print[x];
>
>In my version. "x" was infact the variable "Active" which is an option
>to ButtonBox and created a ton of problems. Of course I could not
>change the name (user driven, and that's why I am running a
>ToExpression on it).
>
>The solution was to not declare Active in the Module and to
>Clear[Active] in the function.
>
>any other insight?
>
>
>Luc Barthelet
>GM the day, Mayor at night
>http://www.simcity.com
>
>

Would not using Block instead of module do it? Block seems to work in
the expected way:

In[49]:=
Clear[x];
test[] := Block[
      {x},
		ToExpression["x=3"]
 Print[x];
      ];
test[];
Print[x];

3
x

Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/



  • Prev by Date: Re: Triangles and trigonometry
  • Next by Date: Re: Variables names
  • Previous by thread: Re: nice Gotcha!
  • Next by thread: Re: nice Gotcha!