Le lundi 23 mars 2015 à 06:33 -0700, Uliano Guerrini a écrit :
>
>
> Il giorno lunedì 23 marzo 2015 14:02:43 UTC+1, Milan Bouchet-Valat ha
> scritto:
> That's because type inference has a hard time checking whether
> the type of k remains the same in the global scope. You can
> declare k as const, or wrap the code in a function.
>
>
>
>
> I don't quite get this point:
>
>
>
> the only way I see to change k while the comprehension is running
> would be another tread, is this the concern?
>
>
> Even so: assuming Array{Any,2,2} won't save against a reassignment to
> k to an array of shorter dimension, or a scalar, or a string...
>
>
> I can't see any gain in assuming Any instead of Float64 but I can see
> the nuisance of having an asymmetric behavior between different
> scopes.
I wouldn't be able to explain you why it's hard, but if it was simple to
fix, believe me, it would have been changed. Others will probably give
you more details, or you can find some in the archives.
Anyway, there are plans to change how type inference works with
comprehensions:
https://github.com/JuliaLang/julia/issues/7258
Regards