Question on symbols in modules
- To: mathgroup at smc.vnet.net
- Subject: [mg17945] Question on symbols in modules
- From: "David Keith" <dkeith at hevanet.com>
- Date: Sat, 5 Jun 1999 02:56:10 -0400
- Organization: Hevanet Communications
- Sender: owner-wri-mathgroup at wolfram.com
Perhaps I am confused about symbols in modules, and also about evaluation. I execute the lines below in V4.0 on NT4.0/SP3: In[1]:= Names["Global`*"] Out[1]= {} In[2]:= test[] := Module[{tmp}, Return[tmp]] In[3]:= Names["Global`*"] Out[3]= {"test", "tmp"} In[4]:= test[] Out[4]= tmp$5 What confuses me is this: line In[2] defines a module with local symbol "tmp". But following this line, a symbol "tmp" has been created in Global context. I thought this would not happen, that the only symbol ever created would be a temporary symbol, some "tmp$N". Further, I thought that the right hand side of In[2] would not actually be evaluated until called. In[4] / Out[4] does display the behaviour I expected, a temporary symbol is used within the scope of the module, but why is "tmp" ever created? Thanks.