D vs C++
foobar
foo at bar.com
Sun Dec 26 00:35:16 PST 2010
Don Wrote:
> bearophile wrote:
> > Walter Bright:
> >
> >> I thought the idea that break and continue were bad died about 25 years ago.
> >> Pascal didn't allow them, and pretty much everyone hated the workaround of
> >> having to use flag variables.
> >
> > You need to add some shades of grey to your palette. break, continue and goto are bad,
>
> Why are break and continue bad? I haven't heard anyone make that claim
> for a very long time.
> BTW everyone I've known who thought they were evil, also wanted to ban
> multiple return statements in a single function. Most of them didn't
> like case statements, either.
Isn't this subjective and depends on what you compare with and also depends on use cases?
Structured programming is considered a huge improvement over gotos and spaghetti code and I thought that OO is considered better than Structured programming. Isn't using polymorphism considered usually better than explicitly maintaining a switch statement?
Of course, all of that depends on your use case and on the programmer. For instance a compiler writer may make better use of gotos compared to structured programming while an average programmer should stick with structured programming to avoid bugs.
My personal opinion is that D should not limit programming styles and should allow got/break/continue/etc.
Of course that doesn't mean that the official D style guide should recommend writing long functions with lots of control statements. :)
More information about the Digitalmars-d
mailing list