These are both semantically the same in the sense that they are binding a name to an object, not modifying the object that was previously bound. Consider:
type Foo b end type Bar a end julia> foo1 = Foo(1) Foo(1) julia> bar = Bar(foo1) Bar(Foo(1)) julia> foo2 = Foo(2) Foo(2) julia> bar.a = foo2 Foo(2) julia> foo1 Foo(1) Assigning foo2 to bar.a doesn't modify the foo1 instance that bar.a was previously bound to, it just changes which Foo object bar.a points to. This is exactly analogous to this: julia> x = foo1 Foo(1) julia> x = foo2 Foo(2) julia> foo1 Foo(1) On Mon, May 12, 2014 at 8:14 PM, Andrew Dabrowski <unhandya...@gmail.com>wrote: > > So it is OO 101, thanks. > > Note that to a programming naif the difference between > > x.a = new > > and > > x = new > > isn't very perspicuous, but in the first the value of x is modified (old > pointer maintained?) while in the second it is replaced (new pointer?). Is > there a rule of thumb I can memorize so as to able to tell when a > variable's value will be modified and when a new value will be created? Is > it just the use of = as assignment? > >