On Sunday, September 14, 2014 8:25:59 AM UTC-5, Laurent Journot wrote:
>
> I am not familar with type management in programing languages but some 
> behaviors are puzzling for a tenderfoot like myself. Here is a piece of 
> stupid code just to illustrate my question (I'm using JuliaStudio):
>

Not directly related to your question, but Julia Studio is going to pin you 
to a quite old version of Julia. I highly recommend you find a way to 
upgrade Julia.
 

> julia> typeof([A[i] for i=1])
>
Array{Any,1}
>

Hey look, it's my second-oldest open issue, good ol' 
https://github.com/JuliaLang/julia/issues/524.

The deal, summarized imprecisely, is that Julia has trouble with typing in 
global scopes, such as at the REPL ("read-eval-print loop," i.e., the 
julia> prompt), to preserve interactivity. So the assumption is that even 
though A is reasonably typed now, it could suddenly change, in which case 
the array comprehension's type will be incorrect. You'll find things work 
better in function contexts.

It is somewhat idiomatic to use typed array comprehensions, which are a bit 
cleaner:

julia> typeof(Int[A[i] for i=1])

should work fine for you.

Thanks for giving Julia a shot! Feel free to ask if you have more questions.

Reply via email to