C subscripts
Andrew Stewart
andrew at hwcs.UUCP
Thu Nov 1 21:10:07 AEST 1984
>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?
I'm sorry, but I do.
>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]
Ah! We follow the hallowed traditions of F*rtr*n... I see.
I have a minor objection, though -
if you consider an array to be a vector of vectors (of vectors, etc, etc)
then the C method is reasonable. The "normal" method treats the array as
a homogeneous mass, rather than a hierarchical structure.
>Of course the older, hopefully obsolescent, method will be supported,
>but it should be discouraged.
I would prefer to see the C method adopted by other languages.
>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.
Ahem - the expression
array_name[more,long,names]
will evaluate the expression 'more', then the expression 'long' and then use the
expression 'names' as the subscript value.
It *is* a sequence of comma-operator expressions.
Not a readable facility, but (like so many gruesomes in C) when you need it,
you *need* it.
--
----------------------------------
"Not a bug, a feature! It's documented, dash it!"
Andrew Stewart, Dept. of Computer Science, Heriot-Watt University,
Edinburgh,
Scotland.
..!ukc!edcaad!hwcs!andrew
More information about the Comp.lang.c
mailing list