Block close check

Brad Roberts braddr at puremagic.com
Mon Dec 11 12:42:25 PST 2006


Chris Nicholson-Sauls wrote:
> 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

Having the compiler care about contents of a comment is a dangerous 
slippery slope.  If you want to do this in some sort of a lint-esque 
tool, then go for it, I guess.

Later,
Brad



More information about the Digitalmars-d mailing list