struct A b::Int; c::Int end
as = [A(1, 1), A(2, 2)]
as[2].c = 3
work without resorting to:
mutable types
recreating A with a changed field
Ideally the produced llvm code might be similar to C equivalent (*pointer).c = 3, so the solution may involve Ref, unsafe methods etc. I checked the documentation, and some GitHub threads, but still can’t figure out how to do this and bypass Julia’s convention for immutability in this particular case.
Thank you @cdsousa, but some code snippets which I encountered in these threads will be available in 1.0+, as I understood. At least methods mentioned are not available in 0.6. It is just very strange that there is no way to do something similar, even with some low-level code, in the current version. But I suspect that I’m missing something, if you would be able to provide a short snippet of working code, I would be grateful.