Block close check

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sat Dec 9 21:34:48 PST 2006



Luís Marques wrote:
> Hi,
> 
> Seeing that the following use of comments is very common:
> 
> #ifndef _BLA_H_
> 
> while (1)
> {
>    ...
>   for(;;)
>   {
>      ..
>   } // for
> } // while
> 
> #endif // _BLA_H_
> 
> Perhaps this could be unenforced by the compiler. For instance:
> 
> version(Windows)
> {
> 
> void doit(int i)
> {
>   while(i > 0)
>   {
>      ...
>     do lot of stuff();
>      ...
>   }(while)
> }(doit)
> 
> }(version)
> 
> What do you think? I tend to avoid these kinds of comments, but for 
> those who use them and for those situations where they are really 
> necessary it would be a lot better to have a compiler enforce it than to 
> have a commentary that might even be incorrect.
> 
> Better syntaxes could be invented, I just wanted an opinion on the gist 
> idea.
> 
> 
> Luís

Personally I do prefer keeping them as comments, as they serve primarily as a visual cue 
in really long functions/classes/structs for me.  (And I like to keep things like this 
"green" in my editor. :))  Although, that said, in a scripting language idea I toyed 
around with, I did have this as an option, such as:

# function doit (Int $i) begin
#   while ($i > 0) begin
#     ...do lot of stuff...
#   end while
# end doit

Ordinarily it uses {}'s but I put the begin/end[name] thing in there.  I just don't think 
it would be very "D like".

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list