C standard for initializations

Philip Almquist ALMQUIST at SU-SCORE.ARPA
Fri Jul 19 10:40:48 AEST 1985


	An alternative which would accomplish the end would be to
add a repetition construct to the preprocessor.  An example, using
one possible syntax, is:

	int foobar[FOOSIZE] = {
		1,
		2,
		3
	#     repeat FOOSIZE - 3
		,27
	#     endrepeat
		}

I believe that such a preprocessor directive would have the following
advantages over the (very reasonable) scheme that you proposed:

 - It also handles repetition in other cases where it can be useful,
   such as loop unrolling.

 - Macro processors tend to be easier to change than compilers.

 - Although I didn't think about it hard enough to be sure, I think
   that there are cases in your syntax where the accidental insertion
   or deletion of a comma could change the meaning of the initializer
   radically without causing any sort of compile-time error.  Since
   commas naturally abound in initializers such an error might be
   hard to spot.  Although such pitfalls abound in C it would be
   nice to avoid adding another one.

					Philip Almquist
-------



More information about the Comp.lang.c mailing list