There isn't currently, but I have suggested this:
https://github.com/JuliaLang/julia/issues/5333


On Sun, Jul 6, 2014 at 4:58 PM, Zenna Tavares <[email protected]>
wrote:

> Perhaps I am not writing idiomatic Julia, but I have immutable objects and
> from them I would like to construct new immutable objects with some fields
> modified.
>
> Is there a simple way to do this?
>
> My current solution relies on reflection.:
>
> function copyImmutable(original, field, value)
>   f = typeof(original)
>   nama = names(Thing)
>   args = ntuple(length(nama), i->if nama[i] == field value else original.(
> nama[i]) end)
>   apply(f,args)
> end
>
>
> This relies on reflection and seems pretty clunky to me, there must be a
> simpler way.  After all, returning modified parts of immutable objects is
> the bread and butter of functional programming.
>

Reply via email to