MathGroup Archive 2006

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

Search the Archive

Removal of Temporary symbols

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69049] Removal of Temporary symbols
  • From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
  • Date: Mon, 28 Aug 2006 02:54:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

Can you help me understand the conditions under which Mathematica
automatically removes symbols with the attribute Temporary that are
created by calls to Module? Please consider the following code:

  $Context="test`"

  Module[{x, y},
    y[] = 0;
    x = y;
  ]

  Names["test`*"]

For me the result of the call to Names is something like {y, y$18}. Why
is the temporary variable y$18, which is no longer referenced by
anything, not being automatically removed?

If I remove the line "x = y;" from the above code, the temporary
variable is destroyed as expected, and the result of the call to Names
is {y}. I'm not clear on why the symbol "y" has been created in the
global ("test`") context in this case; but I'm not bothered by it
(because, unlike the preservation of temporary variables, it doesn't
represent an O(n) memory overhead for evalutating my Module n times).
Can anyone explain this behaviour?

Cheers,

Andrew


  • Prev by Date: Re: Installing Mathematica via SMS
  • Next by Date: Re: Re: Subscript vs SubscriptBox
  • Previous by thread: RE: hatching of the area between two curves?
  • Next by thread: Re: Removal of Temporary symbols