Thanks for this - very helpful.

Just to clarify what you mean by "exactly equivalent" is that while the AST 
may be different, the LLVM generated is identical. Interestingly all the 
above (including f(i)=i appear to be const).

So it was the anonymous nature of the function that causes the differences 
in LLVM. @Jake: that's why I was getting different results. From my 
original post:

julia> f = i->i
(anonymous function)

julia> [f(x) for x in [1,2,3]]
3-element Array{*Any*,1}:
 1
 2
 3

julia> function fn(i)
         i
       end
fn (generic function with 1 method)

julia> [fn(x) for x in [1,2,3]]
3-element Array{*Int64*,1}:
 1
 2
 3

The difference is that the first instance was using anonymous function, 
while the second a named one. Anonymous functions seem to have issues 
preserving type information, even when provably const - but @Jake was still 
right the first case was a global variable and therefore that was my first 
problem.

Hope my embarrassment (somewhat rehashed issue) is of some value to someone.

Regards, Fil.

Reply via email to