Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Compile. Not again

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56470] Compile. Not again
  • From: Maxim <ab_def at prontomail.com>
  • Date: Tue, 26 Apr 2005 01:34:06 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Here's what I get in version 5.1.0:

In[1]:= f = Compile[{}, Module[{L = {0}}, L[[1]]++; L]]

In[2]:= a = f[]

Out[2]= {1}

In[3]:= b = f[]

Out[3]= {2}

In[4]:= Table[f[], {3}]

Out[4]= {{5}, {5}, {5}}

In[5]:= {a, b}

Out[5]= {{5}, {5}}

Each subsequent call to f uses the modified value of L. This also affects  
Table and all the objects involved in assignments such as x = f[] (but not  
x = f[][[1]]), including DownValues[Out]. The problem might be related to  
deciding whether a and b point to the same shared object.

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: Re: multiple choice IF condition
  • Next by Date: Re: multiple choice IF condition
  • Previous by thread: Re: Format[ ] with \[OverBracket] in a package `Private` context
  • Next by thread: Re: Compile. Not again