C standard for initializations

Walter Bright bright at dataio.UUCP
Mon Jul 22 19:38:46 AEST 1985


In article <5 at brl-tgr.ARPA> ALMQUIST at SU-SCORE.ARPA (Philip Almquist) writes:
>	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
>		}
A good idea. But I would rather see the syntax be:

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

Most C preprocessors are already set up to handle text on the current
line, not text on n lines. My scheme would be much easier to implement.
The repeat count would have to be enclosed in parentheses in order
to differentiate it from the repeated text. Large amounts of repeat text
can be handled with a \ continuation character, just like in #defines.



More information about the Comp.lang.c mailing list