"row major" - technically no such thing in C?

L

Lax

Isn't it "technically" meaningless to call C a "row major language,"
since there are no such things as multidimensional arrays in C.

In C you can define arrays of arrays, and the way that the
declarations work (first index closest to identifier defines the
largest arrays) makes it seems like C has row-major multidimensional
arrays

No need to mention "row major" when discussing C if one talks about
"arrays of arrays" and the way C's declarations work "inside to
out." Correct, no?


And thanks to Ian Collins and Walter Robinson for your help with my
previous post (on 'static' externals).
 
K

Kenny McCormack

Lax said:


3.3.2.1 of C89: "Successive subscript operators designate a member of a
multi-dimensional array object."

6.5.2.1(3) of C99: "Successive subscript operators designate an element of
a multidimensional array object."

Nevertheless, it has been stated many times in this newgroup (by regs,
including you; no, I'm not going to google it) that C does not have
multidimensional arrays. It has been stated many times (yes, by you
among others) that it has arrays of arrays.

Of course, you claim that it doesn't have global variables, either...
 
R

Richard Tobin

Lax said:
Isn't it "technically" meaningless to call C a "row major language,"

"Row major" is a bad term anyway, since there's no horizontal or
vertical involved except in the user's interpretation. I prefer to
talk of array subscripts varying in lexicographic order or not. That
is, as your proceed through the memory of the array, do the subscripts
change like the letters in an alphabetical list with the last one
changing fastest, or the reverse?

Given C's syntax for array indexing, it's inevitable that they
should vary lexicographically. Given int a[5][5], a[3] is an
array of 5 ints and a[3][0] ... a[3][4] must be consecutive
in memory.
since there are no such things as multidimensional arrays in C.

I think it would be possible to describe C's arrays without explicitly
talking about multidimensional arrays at all, but the standard does
refer to them. In fact, checking the C Rationale, I see it admits
that the section on multidimensional arrays merely clarifies what
follows anyway from the definition of 1-d arrays.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top