C standard for initializations
Niket K. Patwardhan
lcc.niket at UCLA-LOCUS.ARPA
Thu Jul 18 23:30:02 AEST 1985
Date: Mon, 15 Jul 85 12:33:31 PDT
From: Niket K. Patwardhan <niket>
To: info-c
Subject: C standard on initialization.
I would like this to get transferred to the C standards group as well as see
comments on this proposal.
It has always seemed to me extremely lame that C has no way of specifying that
a particular value is to be repeated N times, without actually typing out the
value N times. Although the draft standard permits initialization of
sub-aggregates via some pretty fancy grouping, it still says nothing about
duplicated values. The only practical way of initializing a large data
structure to something other than all NULLs is to actually write some code to
do it. What I would like to see is this
<initializer> ::=
<assignment-expression>
{ <initializer-list> }
<constant-expression> { <initializer-list> }
{ <initializer-list>, }
If the grammar is too hard to parse, or too unnatural,
the constant expression can follow the initializer list in braces.
The semantics is as follows:
constant-expression has to evaluate to a positive integer.
<constant-expression> { <initializer-list> } is equivalent to
{ <initializer-list> } , { <initializer-list> } , ...... the right number of
times.
or
{ <initializer-list>, <initializer-list>,....... }
or some variation thereof.
On second thought the post-fix constant seems more natural, it having been
often used in documentation with the constant being a superscript.
I would consider a scheme that allowed a single constant to be repeated
insufficient. It is necessary that patterns can be specified as occurring
N times.
More information about the Comp.lang.c
mailing list