That clears up, Thanks Keno. I was thinking about the C++'s reference
(&) , not really thinking about passing the values of pointers. Is
this behavior documented somewhere?
Based on this understanding, I don't know how to rewrite the swap
function to make it work, though it was much easier in C with the
pointer (*) and address (&) or C++ with the reference (&). One idea I
can think about is by constructing tuples
swap=function(a,b)
c=a[1]
a[1]=b[1]
b[1]=c
end
swap((a,0),(b,0))
However, there is something wrong with a[1]=b[1]? I probably need to
delve more into Julia to understand how the tuple works. The tuple
behaves very differently than R or a struct of C pointers.
Yongchao