In general, type inference doesn’t always converge in the global scope.

In this case, you’re seeing that type inference is missing information because 
of the reference to cols, which isn’t a compile-time constant.

I personally recommend using typed comprehensions everywhere for explicitness 
and safety:

Symbol[symbol(“i”) for i in cols]

 — John

On Sep 4, 2014, at 12:29 AM, RecentConvert <[email protected]> wrote:

> For some reason that instance of Julia 0.3 didn't recognize eval or a number 
> of other functions. I was trying to use readtable from DataFrames and it 
> didn't recognize it despite having the latest version. After doing a 
> Pkg.update() only an unused package was updated so I restarted Julia. 
> Afterwards everything worked. If I am able to reproduce the error I will try 
> and submit a bug.
> 
> Your suggestion worked quite well. It's not something I had considered before 
> because I didn't think you could give it a string until I saw IOBuffer used 
> elsewhere recently.
> 
> cols = readcsv(IOBuffer(colsStr))
> 
> One problem I ran across while doing something similar is the type is 
> baffling me.
> 
> julia> y = [symbol("$i") for i in cols]
> 4-element Array{Any,1}:
>  :TIMESTAMP
>  :RECORD
>  :Volt_CR3000_Min
>  :LoggerTemp_CR3000
> 
> julia> y = [symbol("$i") for i in 1:5]
> 5-element Array{Symbol,1}:
>  symbol("1")
>  symbol("2")
>  symbol("3")
>  symbol("4")
>  symbol("5")
> 
>  julia> y = [symbol("$i") for i in [1:5]]
> 5-element Array{Symbol,1}:
>  symbol("1")
>  symbol("2")
>  symbol("3")
>  symbol("4")
>  symbol("5")
> 
> Why is the first instance an Array{Any,1} where the second two are 
> Array{Symbol,1}?
> 

Reply via email to