I was surprised today that the following function doesn't modify an input 
array
function f(x)
    x += 1
end
However, now I understand that x += 1 is just syntactic sugar for x = x + 1.
The reasoning from https://github.com/JuliaLang/julia/issues/7052 makes 
sense.
OTOH, x[:] += 1 does modify the input array.
But that contradicts my mental model of how the language works, because 
x[:] == x.
Is there some special magic going on during parsing?

related: 
https://groups.google.com/forum/#!searchin/julia-users/inplace/julia-users/fHB7WLiiLsQ/U6dJBqcNLg4J

Reply via email to