Re: Module Behavior
- To: mathgroup at smc.vnet.net
- Subject: [mg84683] Re: Module Behavior
- From: "Mariano Suárez-Alvarez" <mariano.suarezalvarez at gmail.com>
- Date: Wed, 9 Jan 2008 03:51:57 -0500 (EST)
- References: <flvcpr$49b$1@smc.vnet.net> <flvo12$7hm$1@smc.vnet.net>
On Jan 8, 9:49 am, Jens-Peer Kuska <ku... at informatik.uni-leipzig.de>
wrote:
> Hi,
>
> no, because the b$* are only removed when no expression
> in your session include the local generated variables
> If you change your Module to
>
> Module[{a, b}, b[1] = 1; a = b[1];]
>
> everything is fine, but with your definition
> a is not evaluated again and so it will hold
> a reference to the local defined variable b.
> If you like you can resolve this by
>
> Module[{a, b}, a = b; b = 1; Evaluate[a]]
>
> and you will see that the global $b* are gone ..
Hmm. The original example was:
Module[{a, b}, a = b[1]; b[1] = 1;]
{Names["a$*"], Names["b$*"]}
What's holding a reference to b$* here?
On the other hand,
Module[{a, b}, a = b[1]; b[1] = 1; Evaluate[a]]
{Names["a$*"], Names["b$*"]}
behaves exactly as in the previous example.
-- m