www.digitalmars.com         C & C++   DMDScript  

D - braces and try blocks

reply "EvilOne" <evilone omen.ru> writes:
There was a discussion concerning having braces around all blocks not long
ago... now the voice from the opposite side =)

I wonder why does C++ require us to put braces around the try..catch blocks?
This seems just not logical, since all other constructs
have single-statement form. And it's actually quite often when I write
something like that:

    try
    {
        var = vars[name];
    }
    catch (out_of_range)
    {
        throw syntax_error("variable '" + name + "' not found'");
    }

All those {}s are just waste of time and space here, IMHO. I think that in D it
would be better not to force these... what do you
think?
Oct 29 2001
parent "Walter" <walter digitalmars.com> writes:
I think C++ isn't consistent <g>.

"EvilOne" <evilone omen.ru> wrote in message
news:9rjqcl$f15$1 digitaldaemon.com...
 There was a discussion concerning having braces around all blocks not long
ago... now the voice from the opposite side =)
 I wonder why does C++ require us to put braces around the try..catch
blocks? This seems just not logical, since all other constructs
 have single-statement form. And it's actually quite often when I write
something like that:
     try
     {
         var = vars[name];
     }
     catch (out_of_range)
     {
         throw syntax_error("variable '" + name + "' not found'");
     }

 All those {}s are just waste of time and space here, IMHO. I think that in
D it would be better not to force these... what do you
 think?
Oct 31 2001