2 ms·
Not sure it's quite that easy. Wouldn't you have to have a size field so the size of the array is known? What integer is the size field? And now the array is
by mpweiher 8y ago
Not sure it's quite that easy. Wouldn't you have to have a size field so the size of the array is known? What integer is the size field? And now the array is a struct, and I dimly recall that passing structures by value came later.
Or do we do it all in the type-system? Except we don't really have much of one. And Pascal just showed what a dumb idea having the size of the array encoded in the type was, with functions that take arrays of different sizes incompatible with each other.
Anyway, I think it's really kind of the other way around: it's not that C has arrays and pointers and wanted there to be compatibility. C doesn't actually have arrays, it only has pointers. What passes as arrays is a minimal bit of syntactic sugar that doesn't affect the semantics, which are just plain pointer semantics.
- pjmlp 8y agoIt is so hard that a large majority of system programming languages do it. That Pascal example is getting tired by now. It only applies to the first edition of ISO Pascal (superceded by ISO Extended Pascal), and improved by any systems language that was born afterwards.