API for internally calculated fields
I read the docs but it is still not clear how one should define the relevant interface for types that have internally calculated fields. Eg
struct Foo
a
b
c
Foo(a, b) = new(a, b, hypot(a, b))
end
I want the user to be able to modify (= create a new immutable with) a and b, and pretend that c does not even exist.
I agree this is a pain point. What I generally recommend is using setproperties/getproperties for public access and constructorof for private access. See also https://github.com/JuliaObjects/ConstructionBase.jl/pull/54#issuecomment-1088765017
Sorry if I am missing the obvious, but could you please provide a suggestion to deal with the above struct so that eg
Accessors.@optic _.a etc works to modify a?
Did you try to overload ConstructionBase.setproperties?