Re: [C--] qc-- fails to compile switch statement

Ning Wang <[email protected]> Sun, 22 Mar 2009 01:27:14 -0700
Newsgroups gmane.comp.lang.c--
Message-ID <[email protected]>
Norman Ramsey wrote:
>  > Don't mean to be offensive, but if the range is known, why should not 
>  > the Nameless one be allowed?
>
> C-- is a compiler-target language.  Compilers should know in which
> cases which arms are to be executed.  The excuse for letting switch
> statements into the tent was that their efficient translation might
> depend on some hypothetical properties of the target machine.  The
> goal was not to provide a convenience to the programmer.
>   
Don't know if I express my thought correctly or not. Let me go back to 
the code snippet.

switch [1 .. 3] i {
       case :              { return (i); } // default 
       case 2 .. 3:        { return (i); } 
}

(*) If the range of i is limited to [1 .. 3], then the empty case represents all unused range values within the limit. 

If a front-ends knows some values in this set of unused range values is infeasible, then it can list only the feasible unused range values for the default. This might result in more efficient translation. 

But I believe in most cases front-ends cannot derive which values are infeasible at runtime, so (*) will provide a convenience to front-end writers as they only need to assert the range limits of switch statement expressions. 
 
Thanks, 
Ning

_______________________________________________
Cminusminus mailing list
[email protected]
https://www.eecs.harvard.edu/mailman/listinfo/cminusminus