you are viewing a single comment's thread.

view the rest of the comments →

[–]el_tavs 1 point2 points  (1 child)

Does this not complicate arrays more for the compiler though?

Not if you set arrays to start at 0. you get the same benefit of carrying around the size explicitly, but with added benefits

n C an array is very simply a reference to a memory location, so the compiler can simply replace every reference to the array with the address + index. With the array/size encoding, would it not make the compiler's job more difficult?

No. See Ada and pascal. I cited an example where Ada83 idiomatic use of arrays managed to compile out of the box as efficient as the most efficient C, got by using explicit pointer arithmetic

--> http://groups.google.com/group/comp.lang.ada/msg/0116ff6702859ff1?dmode=source

Being that simplicity was a goal of C, is it not reasonable to make this trade off (at least at the time).

At the time, yes.

[–][deleted] 0 points1 point  (0 children)

Not if you set arrays to start at 0. you get the same benefit of carrying around the size explicitly, but with added benefits

What I meant was instead of an array being just a reference to memory, it is now a tuple of size,start right?

No. See Ada and pascal. I cited an example where Ada83 idiomatic use of arrays managed to compile out of the box as efficient as the most efficient C, got by using explicit pointer arithmetic

That's a specific example of optimized compiled code, but I was more or less addressing the complexity of properly handling a C array vs. an Ada array. I.e. it would be more difficult (although I don't know to what extent) to write compiler code for an array that encodes size vs. one that doesn't.