[julia-users] Make a Copy of an Immutable with Specific Fields Changed

2014-09-18 Thread Pontus Stenetorp
Everyone,

As a former Python addict, I recently found myself wanting to generate
a copy of an immutable object with only a single or a few values
changed.  I tried to find an answer to this question but either my
search query skills or my lack of energy towards the end of my workday
hindered me.

Concretely, is there a nice idiomatic way to achieve the following.

immutable Foo
a::Int
b::Int
c::Int
end

o = Foo(17, 17, 17)
p = Foo(o.a, 4711, o.c)

When you know that you want to replace the value for `b`, without
having to explicitly enumerate the fields for which you simply want to
copy the previous value.   For Python and named tuples, the operation
would be `_replace`. [1]

Regards,
Pontus

[1]: 
https://docs.python.org/3/library/collections.html#collections.somenamedtuple._replace


Re: [julia-users] Make a Copy of an Immutable with Specific Fields Changed

2014-09-18 Thread Rafael Fourquet
I think the idiomatic way remains to be designed:
https://github.com/JuliaLang/julia/issues/5333.


Re: [julia-users] Make a Copy of an Immutable with Specific Fields Changed

2014-09-18 Thread Pontus Stenetorp
On 18 September 2014 18:22, Rafael Fourquet fourquet.raf...@gmail.com wrote:

 I think the idiomatic way remains to be designed:
 https://github.com/JuliaLang/julia/issues/5333.

Thanks a bundle Rafael, I did indeed miss that issue.  There also
seems to be a pull-request from @nolta implementing it, but it is
waiting for a few other features to be sorted out:

https://github.com/JuliaLang/julia/pull/6122#issuecomment-44579024