One very crude way it can be done:
function mutateimmutable(c::Component)
fields=getargs(c)
mutate!(fields)
if length(fields)==1
return typeof(c)(fields[1])
elseif length(fields)==2
return typeof(c)(fields[1],fields[2])
#etc...
end
end
On 2 May 2015 at 12:43, Mauro <[email protected]> wrote:
> Maybe some pseudo code would make understanding your problem easier?
>
> On Sat, 2015-05-02 at 10:34, Marcus Appelros <[email protected]>
> wrote:
>> This is the use case: abstract Component with a getargs(c::Component) that
>> returns an array with the fields of components, for concreteness lets say a
>> Der type with the fields x and dy. We want to be able to fetch the fields,
>> mutate the array (say replace all :a with :b^2) and then return a mutated
>> immutable instance, and we want it defined generally on Component so no
>> inner constructors. How?
>