This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Missing default in switch


In article <380E68E1.4E65@bell-labs.com>,
Dennis Ritchie  <dmr@bell-labs.com> wrote:
>Nick Maclaren wrote (about compiler treatment
>of switches with and without explicit defaults):
>
>> Except with spectacularly incompetent compilers, the difference is
>> almost certainly negligible, and the whole issue is a matter of
>> robustness.  It would certainly be possible to make the absence of
>> a default: label a constraint violation, but is completely counter
>> to the "spirit of C".
>
>The first sentence is true, but the second irritates.
>Always be alert when the phrase "spirit of C" is wielded.
>It's one of those phrases or words that should tend to make
>you wonder whether its utterer is making a rational argument
>in one direction or another.

That is largely why I put that phrase in quotes!  I was referring to
the following section, early in the Rationale:

    Keep the spirit of C.  The C89 Committee kept as a major goal to
    preserve the traditional spirit of C.  There are many facets of
    the spirit of C, but the essence is the community spirit of the
    underlying principles on which the C language is based.  Some of
    the facets of the spirit of C can be summarized in phrases like:

       Trust the programmer.
       Don't stop the programmer from doing what needs to be done.
       Keep the language small and simple.
       Provide only one way to do an operation.
       Make it fast, even if it is not guaranteed to be portable.

I assert that making a missing default: label into a constraint violation
is clearly counter to the first point, and that adding a standardised
comment to say that it was deliberate is counter to others.

You are better qualified than I am to judge whether there is any merit
in that particular section of the Rationale.  All I know, is that it
has been quoted back at me many times when I have tried to get various
aspects of the language tightened up.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]