by Animats · 8y ago · 0 comments
If only. Here's the original function definition:
void insertion_sort(int const n, int * const p)
"p" is really an array. But C doesn't know that. Rust needs to know.Around 2010, I proposed an extension to C [1] in which you'd write that as
void insertion_sort (int const n, int& p[n])
Instead of a pointer, you'd use a reference to an array. Same calling sequence - the compiler passes a pointer. But with enough info that the callee knows the array size. Rust needs that info to do its job. Somehow, you have to get that info into a C to Rust translator.[1] http://www.animats.com/papers/languages/safearraysforc43.pdf