Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.lang.c Subject: Re: C subscripts Message-ID: <4546@utzoo.UUCP> Date: Sat, 27-Oct-84 19:29:37 EDT Article-I.D.: utzoo.4546 Posted: Sat Oct 27 19:29:37 1984 Date-Received: Sat, 27-Oct-84 19:29:37 EDT References: <195@mouton.UUCP> Organization: U of Toronto Zoology Lines: 52 > Who else out there thinks that > some_array_name[more][long][names] > is actually a good way to do things? An equally-appropriate question is "who out there thinks this is a sufficiently severe problem to be worth fixing?". > Just as we need nested comments, because after all other "great languages" > do, I propose that C support "normal" subscripting. I suggest that C needs neither. > Mathematicians have been around longer than C... So they have, but that doesn't mean we should change C so that the multiplication operator is implicit, like it is in math. "They do it that way in math" is not really a very relevant argument; we do lots of things differently in programming languages. Whether this is a good thing is an interesting question, which I don't suggest debating here, but we have ample precedent for being different. > ... in the name of compatability, which is what the ANSI standard > is all about anyway, the compiler SHOULD ... Compatibility *with* *what*? Surely not with older C implementations, which is the major compabitility concern of the ANSI standard; I'm not aware of any C implementation that has done this. > Now, BEFROE the flames start I KNOW the comma operator exists. > This is not overloading because subscripts are expressions, not statements. > So don't start quoting K&R pg 192 to me. "expressions, not statements"? Surely you are confused; a C "assignment statement" is nothing but an expression with a semicolon after it. The distinction you're after, I think, is the one made in things like function parameter lists: commas are not comma operators unless within parentheses or other bracketing. The expression "x[2,3]" has a perfectly legitimate (albeit peculiar and unlikely) meaning in C right now, and you are changing it. It would not surprise me if somebody, somewhere, had found a use for the current behavior; to judge by some of the furor over cleaning up the preprocessor, there is no feature of C so slimy that someone won't find a real use for it. Remember that "not breaking existing correct programs" is the specific "compatibility" objective of the ANSI C committee; you are proposing a violation of it, for reasons that seem thin. > p.s. Does anyone know of a good preprocessor macro to convert > [a,b,c,...n] into [a][b][c][...][n] for n>1 ? Sounds like you could do it with sed, if things weren't too complicated. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry