[comp.lang.c] Re^2: Why does C hate 2d arrays?

akcs.fish@vpnet.chi.il.us (Gil Winograd) (05/26/90)

Recently I had to write C code to handle a data structure which
consisted of *variably dimensioned* AND *variable size per dimension*
arrays. Of course, it was implemented as a one-dimensional array,
through which I had to go through involved calculations to get the
index right
! (Especially when doing loops through some of the dimensions but
not others...) Does Algol/Pascal handle this situation any better?

-* Gil

dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) (05/28/90)

In article <265e1de4-26d.17comp.lang.c-1@vpnet.chi.il.us> akcs.fish@vpnet.chi.il.us (Gil Winograd) writes:
>Recently I had to write C code to handle a data structure which
>consisted of *variably dimensioned* AND *variable size per dimension*
>arrays. Of course, it was implemented as a one-dimensional array,
>through which I had to go through involved calculations to get the
>index right
>Does Algol/Pascal handle this situation any better?

No, the number of dimensions is fixed in Algol6{0,8}/Pascal.
APL & APL2 are the only languages I know of which allow changing the
number of dimensions of an array at run-time.
Maybe we should continue this non-C discussion in comp.misc ?
-- 
Dolf Grunbauer      Tel: +31 55 433233 Internet dolf@idca.tds.philips.nl
Philips Information Systems            UUCP     ...!mcsun!philapd!dolf
Dept. BS Software,  P.O. Box 245, 7300 AE Apeldoorn, The Netherlands 
read: error in reading .signature

diamond@tkou02.enet.dec.com (diamond@tkovoa) (05/28/90)

In article <755@ssp11.idca.tds.philips.nl> dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) writes:
>In article <265e1de4-26d.17comp.lang.c-1@vpnet.chi.il.us> akcs.fish@vpnet.chi.il.us (Gil Winograd) writes:
>>Recently I had to write C code to handle a data structure which
>>consisted of *variably dimensioned* AND *variable size per dimension*
>>arrays. Of course, it was implemented as a one-dimensional array,
>>through which I had to go through involved calculations to get the
>>index right
>>Does Algol/Pascal handle this situation any better?
>
>No, the number of dimensions is fixed in Algol6{0,8}/Pascal.
>APL & APL2 are the only languages I know of which allow changing the
>number of dimensions of an array at run-time.
>Maybe we should continue this non-C discussion in comp.misc ?

Mr. Grunbauer's excerpt of Mr. Winograd's posting (which I did not edit
any further) has 5 lines about C and one line about non-C.  The two
postings together have 5 lines about C, 4 lines about non-C, and one
line asking a question.  I'd say the answer is no, that a posting which
is half about C, and compares C to other languages, somewhat suits the
comp.lang.c newsgroup.

I also just observed Henry Spencer telling another poster that his
question belonged in a hardware-specific newsgroup.  The person who
posted the question did not know that his problem was machine-dependent.
He properly read the manual, tried his best to obey it, and wondered
why it didn't work.  Correct advice would be to say that in a hardware-
specific newsgroup, a useful answer could be obtained more easily.

Yes, there's a lot of junk that doesn't belong in comp.lang.c, and
like many others, I am also irritated by wading through it.  But let's
not go overboard and criticize innocents.

-- 
Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
Proposed group comp.networks.load-reduction:  send your "yes" vote to /dev/null.