On 05/12/2017 10:49 AM, Martin Sebor wrote:
On 05/10/2017 04:14 PM, Daniel Santos wrote:
Well my primary goal is programming with values that are constant in the
compiler.  There is no language in any C specification (that I'm aware
of) for a "compile-time constant", but the concept is very important.
So just because some expression is a compile-time constant doesn't mean
we morph into a "constant expression" (as per the spec), even with
__attribute__((const)).

The C committee has discussed extending the set of expressions
that are considered constant in C2X.  A proposal was submitted
last year that, at least in spirit, gained pretty broad support
(the finer details, including the syntax, especially the reuse
of the register keyword, are likely to evolve):

  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2067.pdf

The C committee's charter for C2X is to increase compatibility
with C++, so new language features with that effect have a good
chance of being considered.

I don't expect C2X to go as far as to add something as complex
as templates but some on the committee are working on enhancing
support for generic programming (via _Generic).  Interestingly,
C11 (by accident) introduced a requirement for implementations
to support true type genericity in the form of the C11 atomic
APIs.  It may not be too far out there to propose to generalize
the underlying machinery and make it available to programs (as
opposed to just the standard library alone).

Martin

Thank you for this! It sounds like I need to read up on what is in the works with the C committee and maybe prepare my own proposal and become involved. I see the monetary cost of not having generic support as very high -- you end up with more boiler-plate code that has to be maintained, thus increasing development time and the chance for bugs. It also takes more time to analyze the code, diagnose problems and get new programmers up to speed.

Thanks,
Daniel

Reply via email to