> > This shows the first lambda arg again as :(j::Any) of type :(::). In my > real code, it was at least figuring out in the second lambda arg to type > "j" as {:j,Int64,0} but in this example it doesn't even figure out that "j" > has to be of some Unsigned type and punts back to Any ({:j, Any, 0}).
I'm not sure I follow -- I don't see any type annotation of `:(::)`. However, more generally, there are currently some (known) limitations of Julia's type inference for anonymous functions. A do-block creates an anonymous function, so I would guess that is the underlying issue with the inferred types here. (By the way, have you seen the Cartesian macros in base? http://julia.readthedocs.org/en/release-0.3/devdocs/cartesian/) On Mon, Apr 13, 2015 at 7:46 PM, Todd Anderson <drtod...@comcast.net> wrote: > Here's a small example: > > function nef(weights, input_B) > delta_B = cartesianarray(Float64, (input_B),) do j > sum(weights[spikes_A, j]) > end > end > > ct = code_typed(nef, (Array{Float64,2}, Int64)) > > println(ct) > > Here's the output: > > {:($(Expr(:lambda, {:weights,:input_B}, > {{:#s2,:delta_B},{{:weights,Array{Float64,2},1},{:input_B,Int64,0},{:#s2,Any,18},{:delta_B,Any,18}},{}}, > :(begin > #s2 = cartesianarray(AST(:($(Expr(:lambda, {:(j::Any)}, > {{},{{:j,Any,0}},{{:weights,Array{Float64,2},1}}}, :(begin # > /mnt/home/taanders/pse-hpc/benchmarks2/nengo/ex2.jl, line 3: > return sum(getindex(weights,spikes_A,j)) > end))))),Float64,input_B::Int64) > delta_B = #s2 > return #s2 > end))))} > > This shows the first lambda arg again as :(j::Any) of type :(::). In my > real code, it was at least figuring out in the second lambda arg to type > "j" as {:j,Int64,0} but in this example it doesn't even figure out that "j" > has to be of some Unsigned type and punts back to Any ({:j, Any, 0}). >