Author: David Keaton
Author Affiliation: Keaton Consulting
Postal Address: 1630 30th St. No. 311, Boulder, CO 80301 USA
E-mail Address:
Telephone Number: +1 303 782 1009
Fax Number:
Sponsor:
Date: 1995-05-29
_ Editorial change/non-normative contribution _ Correction X New feature _ Addition to obsolescent feature list _ Addition to Future Directions _ Other (please specify) _____________________________
_ Environment
X Language
_ Preprocessor
_ Library
_ Macro/typedef/tag name
_ Function
_ Header
One of the uses of C++ constructors is to supply default values for some members, and allow other members to be initialized via arguments to the constructor. The static portion of this functionality can be emulated in C without the run time overhead by providing a mechanism to specify a nonzero default initial value on a per-type basis. Then at each variable definition, any member values that are desired to be different from the default can be filled in using Designated Initializers.
In addition, nonzero default initial values could be used to shorten the specification of Compound Literals for a given type, with only the nondefault members being filled in via Designated Initializers.
Note that there are other uses for C++ constructors as well; these are not addressed here. However, nonzero default initial values may relieve some of the pressure to implement full-blown constructors in C, with their attendant run time overhead.
The author will monitor interest in this subject before providing a more detailed proposal.