Discussion starts here: 
https://github.com/JuliaLang/julia/issues/249#issuecomment-3056793

On Tuesday, January 28, 2014 4:19:59 AM UTC-6, Ivar Nesje wrote:
>
> Sorry, the top statement was not (intended to) refer to the semantics in 
> the 1. bullet point. That was not obvious from what I wrote, but I was 
> thinking about 2 and 3. Thanks for correcting me.
>
> I agree that it is a mistake in the design of Julia to not define += as a 
> function. If the expression `a += b` would be rewritten to `a = +=(a,b)` 
> that would make it possible to define mutating += functions for mutable 
> types, and immutable types would continue to work as before. I tried to 
> search for this on github but `+=` returned 0 hits on issues, so I think 
> github is interpreting the query to mean something else.
>
> Ivar 
>
> kl. 04:27:31 UTC+1 tirsdag 28. januar 2014 skrev Rob Speer følgende:
>>
>> On Saturday, 25 January 2014 03:49:11 UTC-5, Ivar Nesje wrote:
>>>
>>> It is nice that you raise this issue. I think most of the others working 
>>> with Julia has experience from C or Python which also have the same 
>>> semantics. I'll make an attempt to sum up how things work in this case.
>>>
>>
>> Julia doesn't have the same semantics as Python here, if that's what 
>> you're saying. In Python, += is an operation that types can implement 
>> separately from +, and is usually implemented in-place. 
>>
>> Here's a NumPy example, because NumPy arrays are closest to Julia arrays, 
>> and += on plain old lists is Julia's "append!" instead:
>>
>> >>> a = np.array([1, 2, 3])
>> >>> b = a
>>
>> >>> a += 1
>>
>> >>> b 
>>
>> array([2, 3, 4])
>>
>>
>>

Reply via email to