MathGroup Archive 2004

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

Search the Archive

Re: Compile


Yet another peculiarity: compare

In[1]:=
Module[{y = x}, Compile[{x}, Evaluate @ y]]
Block[{x = 1}, %[2]]

Out[1]=
CompiledFunction[{x$},x,"-CompiledCode-"]

Out[2]=
1.

and

In[1]:=
Module[{y = x}, Compile[{{x, _Real}}, Evaluate @ y]]
Block[{x = 1}, %[2]]

Out[1]=
CompiledFunction[{x},x,"-CompiledCode-"]

Out[2]=
2.

Or, even simpler,

In[1]:=
Function[x, Compile[{x}, x]][1]
Function[x, Compile[{{x, _Real}}, x]][1]

Out[1]=
CompiledFunction[{x},x,"-CompiledCode-"]

<warning messages>

Out[2]=
Compile[{{1,_Real}},1]

So the idea was to treat Compile as a scoping construct, but the possibility of a
different format of the first Compile argument was overlooked.

Maxim Rytin
m.r at prontomail.com



  • Prev by Date: Re: how to delete duplicate items in the same list
  • Next by Date: using functions with package name prefixed.
  • Previous by thread: RE: RE: RE: Re: Compile
  • Next by thread: Re: Mathematica 5.0 "RunThrough" Command