The Weird and The Wonderful
The Weird and The Wonderful forum is a place to post Coding Horrors,
Worst Practices, and the occasional flash of brilliance.
We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid
workarounds and developers just not quite getting it. And then somedays we come across - or write -
the truly sublime.
Post your Best, your worst, and your most interesting. But please - no
programming questions . This forum is purely for amusement and discussions on code snippets. All
actual programming questions will be removed.
You can create a similar block in C# using braces. And if you're particularly masochistic, you can mimic the
Member 7989122 wrote:This is just a way to make a block that is not a loop, not a conditional statement, not a function body, but just a sequence of smaller blocks put togeteher for some purpose
EXIT with a goto[^].
IF PreparationWentWrong THEN EXIT ManySteps;
IF Specialcondition THEN EXIT ManySteps;
if (PreparationWentWrong) goto ExitManySteps;
if (Specialcondition) goto ExitManySteps;
ExitManySteps: But this example would probably be better handled with SEH - if something went wrong, you don't want to depend on the caller checking a return value, or some unrelated property.
That could potentially lead to ambiguity - which statement(s) are part of the condition, and which are part of the branch? Even if it's always obvious to the compiler, it may not always be obvious to the person reading the code. And the main point of any code is to be read and understood by a person.
Member 7989122 wrote:When you say "Here comes a conditional block" by using an IF keyword, you should not need to use an open parenthesis to say that "here comes the condition".
No, it's a major difference in the language design. (And yes, the language was designed. No need for the sarcisti-quotes.)
Member 7989122 wrote:That is a major flaw in the language "design".
English doesn't have accents on any letters; you're just supposed to know how to pronounce them. Does that makes the accents in other languages a flaw? Or is English the flawed language for not having them?
Just because something is different doesn't mean that it's flawed.
Agreed. But code that's nested that deeply is crying out to be refactored anyway.
Member 7989122 wrote:At the end of a deep nest, in C languages there may be a lisp-like sequence of closing parentheses, and you may have a hard time seeing which one closes the outermost loop, the while, the function, the class...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.