Declarations in switches, errors

Chris Torek chris at mimsy.UUCP
Sun Oct 1 15:32:51 AEST 1989


In article <30540 at news.Think.COM> barmar at kulla (Barry Margolin) writes:
>Here's something I think is closer to the original poster's complaint:
>why does the standard permit initializers in declarations at the head
>of a switch body, if they are required to be ignored?

It makes the language simpler conceptually: all variable declarations
are of the form

    <type> <var> <optional initialiser> [, <var> <optional initialiser>]* ;

Even a compiler that is only 1/3 decent% will warn about unreachable
initialisers.

Note that the <optional initialiser>s are, as Doug has already pointed
out (it seems to require a great deal of repetition to get these to sink
in), treated as though they were executable statements when they apply
to automatic (as opposed to static or global) variables.
-----
% 1/3: `less than half'
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.std.c mailing list