Module Behavior
- To: mathgroup at smc.vnet.net
- Subject: [mg84660] Module Behavior
- From: "Marcelo Mayall" <mmayall at bol.com.br>
- Date: Tue, 8 Jan 2008 03:37:46 -0500 (EST)
One of the main features of the function Module is that you can specify symbols to be treated as local. For example: In[1]:= Module[{a, b}, a = b; b = 1;] In[2]:= {Names["a$*"], Names["b$*"]} Out[2]= {{}, {}} However, if we change the local symbol "b" to "b[1]" it does not treat as local anymore. In[3]:= Module[{a, b}, a = b[1]; b[1] = 1;] In[4]:= {Names["a$*"], Names["b$*"]} Out[4]= {{}, {"b$69"}} And each time you execute this command line a new variable "b$*" will be created. In[14]:= Module[{a, b}, a = b[1]; b[1] = 1;] In[15]:= {Names["a$*"], Names["b$*"]} Out[15]= {{}, {"b$69", "b$77", "b$79", "b$81", "b$84", "b$86", "b$88", "b$90", "b$92", "b$94"}} Shouldn't the function Module treat the symbol "b[1]" as local too? Is this an expected or unexpected result? Regards, Marcelo Mayall
- Follow-Ups:
- Re: Module Behavior
- From: Carl Woll <carlw@wolfram.com>
- Re: Module Behavior