why ; ?
Bruce Adams
tortoise_74 at yeah.who.co.uk
Fri May 9 16:07:27 PDT 2008
On Thu, 08 May 2008 18:28:23 +0100, Michael Neumann <mneumann at ntecs.de>
wrote:
> Nick Sabalausky wrote:
> > "Michael Neumann" <mneumann at ntecs.de> wrote in message
> > news:48231B20.1080009 at ntecs.de...
> >> Actually, IMHO any C-style syntax has much more sever problems
> leading
> >> to hard to find bugs:
> >>
> >> if (a)
> >> s1;
> >> s2;
> >>
> >
> > I can't say I've ever found that to be a problem. But maybe that's
> just me.
>
> Me neither. But it's annoying to have at least 3 different style
> guidelines for C-style syntaxes.
>
> if (a) b;
>
> if (a)
> b;
>
> if (a) {
> b;
> }
>
> if (a)
> {
> b;
> }
>
> if (a)
> {
> b;
> }
>
> if (a)
> {
> b;
> }
>
> And so on :).
>
> Compare that with how many choices you have when using "if ... end"!
>
> Regards,
>
> Michael
I thought D had dropped single statement if's for this very reason. I must
be mistaken. Many a (C) coding
style guide strongly encourages embracing even single statements in
constructs like this.
You can go further with the idea. After all you can casuse ambiguity
between e.g nested loops as well.
if (a) {
while(b) {c}
}
versus
if (a)
while(b)
c
wend
fi
or whatever.
You can mess around with this stuff forever without increasing programmer
productivity signficantly.
The real gains are when you hit on improvements to semantic
expressiveness. I'd much rather have the next
foreach than waste time worrying about } versus fi, endif etc.
Regards,
Bruce.
More information about the Digitalmars-d
mailing list