I wanted to ask whether julia arrays support something like C++ vector swap.
That is, swap!(A,B) should swap the contents of both arrays A,B, and throw if they don’t have the same type (essentially swap sizes and data-pointers of the arrays).
I think that this can only be done either by horribly abusing pointers, or by some ccall into the runtime (I did not find it in array.c nor array.jl, but maybe I’m blind?).
Does such functionality exist in some corner of the runtime?
Is there a fundamental reason why this cannot be made to work? If I have pointer-arrays of different age, then I need to possibly root the young one; if shared, then maybe just give up and throw?
(while I am not opposed to horribly abusing pointers, this specific case probably wants to be written in C and either linked against the runtime or included in array.c)
(adding another layer of indirection by wrapping array does not cut the cake, nor does copying the contents)