On Friday, May 6, 2016 at 2:18:42 PM UTC-4, David Dill wrote: 
>
> It's a bit surprising that, if d1 is mentioned for the first time in d1 = 
> d2 = Dict() in f7 below, the inferred type of d1 is different from the 
> inferred type of d2, especially since the inferred type is different in d8.
>
 
The type of d2 isn't inferred -- you explicitly declared it as 
Dict{Int,Int} in the line above.

As for d1, the key thing to remember is that the value of an assignment 
operation is equal to the *right-hand* side.   That is, in a=b=c, c is 
assigned to both a and b.  More explicitly, in your example, d1 = d2 = 
Dict() is equivalent to

     let temp = Dict() # gives a Dict{Any,Any}
         d2 = temp   # requires a conversion (hence a copy) since d2 was 
declared as Dict{Int,Int}
         d1 = temp   # since d1's type was not declared, it is inferred to 
be that of temp, hence no copy is needed
     end

Reply via email to