MathGroup Archive 2007

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

Search the Archive

Re: memory release problem in mathematica6.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83439] Re: memory release problem in mathematica6.0
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 20 Nov 2007 03:57:15 -0500 (EST)
  • References: <fhegac$m08$1@smc.vnet.net> <fhh71o$8h2$1@smc.vnet.net>

Yaroslav Bulatov wrote:

> Like several posters pointed out, it's saved in Out[].
>
> It's a bit confusing because documentation for "CompoundExpression"
> says that for expression of the form expr1;expr2; it's the value of
> expr2 that's saved
>
> so if I do
> "A = RandomInteger[{1}, 100000000]; Clear[A];"
>
> It should save value of Clear[A], which is null, but instead it saves
> value of AA = RandomInteger[{1}, 100000000]

Yes, the documentation is misleading, indeed. The last paragraph of the
"More Information" section of the help page about "CompoundExpression
(;)" reads,

"expr1; expr2; returns value Null. If it is given as input, the
resulting output will not be printed. *Out[n] will nevertheless be
assigned to be the value of expr2.* [emphasize added]"

The last sentence implies that whatever the value of expr2 is, this
value is saved into Out[n] regardless of its display (display that is
controlled by the presence or absence of a semicolon).

Now, as you pointed out, Clear[] returns Null, and this Null from Clear
is not store in Out[n]. This behavior is not specific to Clear, however,
but applies to any expression that returns Null (like Print[] and Do[]
in the example below).

-----------------------------------------------------------------
Indeed, the documentation should clearly explain that this is the
_last-non-null value_  of a compound expression that is stored in
Out[n], as illustrated by the following example.

In[1]:= a = 1; Table[a += 1, {10}]; Print[a]; Do[a += 1, {10}]

During evaluation of In[1]:= 11

In[2]:= %

Out[2]= {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
-----------------------------------------------------------------

Regards,
--
Jean-Marc


  • Prev by Date: more issues with v.6.0.1
  • Next by Date: Re: RandomChoice does not accept null weights
  • Previous by thread: Re: memory release problem in mathematica6.0
  • Next by thread: Re: memory release problem in mathematica6.0