Hi all,

suppose i have a custom type

julia> type mytype
       x :: Float64; 
       # constructor
       function mytype()
           new(1.1)
       end
       end

julia> my=mytype()
mytype(1.1)

and I want to modify x many times, always keeping track of the most recent 
state. suppose x is a large object, so I would like to avoid copies if 
possible. Let's say i want to use function "myadd" on that type:

julia> myadd = function(z,my::mytype)
       return my.x + z
       end

then the question is: is this the fastest way to change x?

julia> my = myadd(3.0,my)
4.1

I guess my question could also be: how can I write a myadd!() function? 
obviously this

myadd(3.0,my)
julia> my.x
4.1

leaves x in my unchanged.

thanks
florian

Reply via email to