C subscripts
ryan at mouton.UUCP
ryan at mouton.UUCP
Fri Oct 26 23:37:29 AEST 1984
I hope I am not bringing up and old issue
but this discussion about nested comments brings
a similiar niggle to mind; one that I am certain
should raise an equally fruitful controversy.
I am talking about C's arcane subscripting syntax.
Who else out there thinks that
some_array_name[more][long][names]
is actually a good way to do things?
Just as we need nested comments, because after all other "great languages"
do, I propose that C support "normal" subscripting.
Mathematicians have been around longer than C; Fortran too;
so, in the name of compatability, which is what the ANSI standard
is all about anyway, the compiler SHOULD accept
some_array_name[more,long,names]
Of course the older, hopefully obsolescent, method will be supported,
but it should be discouraged.
I would also propose one small, new, preprocessor built-in,
SUBTYPE which would be defined OLD or NEW
as in
#if SUBTYPE == OLD
fprintf(stder, "buy a new compiler");
so programmers know what's going on.
Not defining SUBTYPE would be considered in an optional subsection
to the standard. These details I leave to those who know best.
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.
If you're still confused think about it this way:
a[x,y,z] saves 20% more disk space than a[x][y][z]
and is much easier to type too!
respectfully,
Tom Ryan
p.s. Does anyone know of a good preprocessor macro to convert
[a,b,c,...n] into [a][b][c][...][n] for n>1 ?
More information about the Comp.lang.c
mailing list