I would add, do you know if there are any intentions to remove it in the future?
Is it because it's not so a demonized statement when you write low level code (e.g. maybe mixing C++ and assembler)?
I would add, do you know if there are any intentions to remove it in the future?
Is it because it's not so a demonized statement when you write low level code (e.g. maybe mixing C++ and assembler)?
I would add, do you know if there are any intentions to remove it in the future?
No, there are not. It has never been proposed, and if it were, it would almost universally be laughed out of committee. Not just because of BC, but on the merits of the idea.
goto
is a tool of marginal usefulness, but it is useful. Most new C++ programmers don't even learn how goto
works in their introductory learning, so it's not like there's a rash of people abusing the feature. There's nothing to be gained by removing it, save for pandering to purists who have taken "Goto consider harmful" not as a suggestion or even as a default position, but as religious doctrine.
There are complex cases where goto
is the least bad and most clear of the various control flow structures available to you. They may be rare, but they do exist, so there's nothing to be gained from removing the feature.
When writing a programs to generate a C or C++ source code to perform some task (e.g. when transpiling code from some other language into C or C++), the mix of constructs that one will output will often be quite different from the range of constructs one would use if writing C or C++ code directly. If one is writing a transpiler for a language which has some control structures that C and C++ wouldn't conveniently support without using goto
, allowing a transpiler to implement such structures using goto
will often make things much more convenient than requiring it to add flags or other such hackery to work around the lack of goto
.
At the assembly level, there is only goto. No braces. Jmps are really gotos. C++ has always tried to make everything possible. Hence goto will not be removed. 99.99% of apps don't need it, but 0.01% do.
It's easily implemented in the compiler as well.
Besides, goto is not likely to be abused nowadays. How many students even learn there is such a keyword? And if they do notice it, they are unlikely to know where to use it. Goto was dangerous back in the spaghetti coding days, but not today.