Xref: utzoo comp.lang.c:7474 comp.lang.fortran:453 Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: Conformant Arrays in C Message-ID: <7297@brl-smoke.ARPA> Date: 20 Feb 88 15:43:06 GMT References: <42529@sun.uucp> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 32 Keywords: ANSI C Fortran In article <42529@sun.uucp> dgh%dgh@Sun.COM (David Hough) writes: > The Draft, like traditional C, disallows the equivalent > void matmul(x,lx,cx,...) > int lx, cx; > double x[lx][cx] ; Yes, indeed, this is a pain. I discussed the possibility of allowing something like this several years ago with Dennis Ritchie and Steve Johnson, and the consensus was that it was "doable", although specifying it correctly is tricky. > void matmul(double a[?ar][?ac], /* ar >= p, ac >= q */ > double b[?br][?bc], /* br >= q, bc >= r */ > double c[?cr][?cc], /* cr >= p, cc >= r */ > int p, /* 0 <= p <= min(ar,cr) */ > int q, /* 0 <= q <= min(ac,br) */ > int r) /* 0 <= r <= min(bc,cc) */ I didn't see how this proposal would work. For correct code to be generated, all but one of the array dimensions has to be known via the calling sequence. There seem to be only two ways to achieve this: (1) rely on explicit dimension parameters, as in the first example; (2) automatically pass extra size information along with the array address. The second approach is incompatible with current treatment of arrays, unless the function prototype has parameters declared some special way (perhaps using yet another type qualifier), so that the compilers will pass array information specially for the particular function. In other words, to make method (2) work, more must be involved than just the function definition. Is this what was intended by your second example? (Since the body of the example didn't make use of ar, ac, etc., it's hard to be sure.)