Passing an array of structures through `ccall`

I don’t believe it is possible to have st_test mutable and have it stored contiguous in memory in an array.

But is mutability of the array elements actually important? Or is it ok to do something like the following when you need to update an element of the list:

old_element = array[1]
new_element = st_test(4, old_element.d, old_element.s, old_element.a, old_element.b)
array[1] = new_element

You can hide this messiness behind a helper function for now, but I believe there is syntax on the horizon that will make this less annoying

https://github.com/JuliaLang/julia/pull/21912

1 Like