       Re: Compile. Not again

• To: mathgroup at smc.vnet.net
• Subject: [mg56490] Re: [mg56470] Compile. Not again
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Tue, 26 Apr 2005 21:52:50 -0400 (EDT)
• References: <200504260534.BAA14453@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```  Another strange (to me) observation: consider the following function g

g = CompiledFunction[{}, {{2, 1, 0}}, {0, 4, 0, 0, 1}, {{1, 5}, {7,
{0}, 2,
1, 0}, {4, 1, 0}, {64, 0, 0, 0, 0,
1}, {4, 1, 0}, {4, 1, 2}, {24, 1, 2, 3}, {65, 0, 0, 0,
0, 3}, {2}}, Function[{}, Module[{L = {0}}, L[]++; L]],
Evaluate]

g ought to be exactly the same as f (look at InputForm[f]). However
every time you evaluate g[] you will get {1} (at least I do with
Mathemaitca 5.1 on Mac OS X).

Anndrzej Kozlowski

On 26 Apr 2005, at 14:34, Maxim wrote:

> *This message was transferred with a trial version of CommuniGate(tm)
> Pro*
> Here's what I get in version 5.1.0:
>
> In:= f = Compile[{}, Module[{L = {0}}, L[]++; L]]
>
> In:= a = f[]
>
> Out= {1}
>
> In:= b = f[]
>
> Out= {2}
>
> In:= Table[f[], {3}]
>
> Out= {{5}, {5}, {5}}
>
> In:= {a, b}
>
> Out= {{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[][]), 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: odd mathematica blindspot
• Next by Date: Re: Using BarChart in a Widget
• Previous by thread: Re: Compile. Not again
• Next by thread: Re: Compile. Not again