MathGroup Archive 2005

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

Search the Archive

Re: How to free memory?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59837] Re: How to free memory?
  • From: "Richard J. Fateman" <fateman at eecs.berkeley.edu>
  • Date: Tue, 23 Aug 2005 04:51:41 -0400 (EDT)
  • Organization: UC Berkeley
  • References: <de46jr$r62$1@smc.vnet.net><de6lru$cg5$1@smc.vnet.net> <de9cs2$q5l$1@smc.vnet.net> <debsf8$969$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com


Wonseok Shin wrote:

>
> Wow!  What you are saying is very huge to me.  I though that the scope
> of the variables defined in a Module is just inside the Module.  But as
> you wrote, the variables defined in a Module can be referred to from
> outside (by referring e$nnn in my case), and they are effectively
> global variables!  This is quite different from the concept of local
> variables in the ordinary programming languages like C and C++.

Yes.

> 
> Then, is there any way to define local variables resembling those of C
> and C++, which are automatically destroyed outside some blocks like
> Module, With, or Block?
> 
> Or, how can I remedy my code, which generates a lot of unwanted
> (effectively global) variables?  I may do Remove or Clear the variables
> like e1, e2, h1, and so on before returning {e, de}.
> 
> Since the concept of local variables which are automatically generated
> inside a block and destroyed outside the block is very useful in C and
> C++, I'm sure that there is some elegant way to achieve the same thing
> in Mathematica.

Why are you so sure? Module was a particularly inelegant way of
trying to correct the problems with Block (and so corrected only some
of them).  Maybe Module should be redefined to actually use local
(stack-allocated) variables as you and most other people with previous
experience in programming assume.
RJF


> 
> Thanks,
> Wonseok Shin
> 


  • Prev by Date: Re: Simplifying Conjugate[] with 5.2 Mac
  • Next by Date: Re: with 5.2 Mac
  • Previous by thread: Re: How to free memory?
  • Next by thread: Re: How to free memory?