Block close check

Chris Nicholson-Sauls ibisbasenji at gmail.com
Mon Dec 11 12:29:00 PST 2006


BCS wrote:
> What might be the most useful would be for the compiler to check for a 
> comment at the end of a block and if it clams to close a block that it 
> doesn't, emit a warning.
> 
> 
> //////these pass
> 
> 
> for(int i=0;i<10;i++){
>     ...
> }//CLOSE for i
> 
> while(j<k){
>     ...
> }/*CLOSE while j < k this block has more comments */
> 
> outer: switch(n){
>     ...
> }/+CLOSE outer: +/
> 
> 
> //////these fail
> 
> 
> inner: switch(n){
>     ...
> }//CLOSE outer:
> 
> for(int i=0;i<10;i++){
>     ...
> }//CLOSE for j

Now that's actually not a bad idea.  Keeps it "green" when editing, remains optional, and 
provides more than just the visual cue (if the compiler in use supports it).  Might've 
been useful in some of the more convoluted things I've written (like a few parsers/lexers 
with insane nesting).

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list