Okay I think we can do that. We need ways to hook into @set. I think
@set obj.x = 1.0
should call setproperty(b, Val{:x},1.0) and then the user could overload setproperty to get any kind of interesting behaviour. The default implementation of setproperty should be something like
- destructure
objinto properties - manipulate properties
- construct
new_objfromtypeof(obj)and properties
Each step should be overloadable. 3) is where you could hook in your
Reconstructables.constructor_of(::Type{<: B{T}}) where T = B{T}
What do you think?