Is C++ too complex?

Started by
121 comments, last by Vortez 11 years, 3 months ago

[quote name='Stroppy Katamari' timestamp='1355422105' post='5010294']
[&](){ /* may return from inner loop here */ }();


I am not familiar enough with lambda expressions to know if this is cool or horrible. smile.png[/quote]It's Cornstalks' function suggestion, just replacing the function with a lambda in order to fix the (potential) issues you pointed out. Those issues are exactly the kind lambdas are intended to deal with, and thus this piece of code is totally mundane, not any sort of trickery. I'd argue it is not horrible because it is straightforward and not a hack, and it is a little bit cool because it is straightforward and not a hack. smile.png
Same natural code structure as with the goto solution, but no goto, no contrived names or messy argument lists.[/quote]
The goto solution has the same natural code as with the lambda-expression solution, but no lambda expression and no returns that don't actually return from the function.
[/quote]I'm not claiming it is massively better than the goto (if at all better), but it's obviously about as convenient, and also works for people who don't want to use goto or are prohibited from doing so.

The returns do return from the function. You are just thinking about the wrong function.smile.png
Advertisement
The problem with C++ is not the complexity.
There are many ways that C# and Java are more complex than C++ is.

The problem with C++ is that it is a mess.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I never understood this hated toward goto... it's not like using 1 or 2 goto in a program gona make the code unreadable or spagetified like it was back in the assembly days (when every branching was coded using gotos), from wich i believe that fear/hate come from. It's like not wanting to use a tool just because someone told you to :)

This topic is closed to new replies.

Advertisement