I'm having hard time understanding, why the compiler requires using break statement. It's not possible to miss it since the fall through is now allowed. I see the reason for the break in C or C++, but is it needed here.
Why it's not a built-in behavior to break after a case is over ? Isn't it just a syntax with no semantic?
Sorry, if it's a stupid question.
EDIT: The fall through is allowed only when the case is empty. When there is a statement there you can't omit the break statement. So, it's a different matter.
Quote from wikipedia: "A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix." The creators want that everyone "see" his language. So he named it "C". C is about the tone C.
C is highly portable and is used for scripting system applications which form a major part of Windows, UNIX, and Linux operating system. C is a general-purpose programming language and can efficiently work on enterprise applications, games, graphics, and applications requiring calculations, etc.
C is a general purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. It was named 'C' because many of its features were derived from an earlier language called 'B'.
The C programming language is so popular because it is known as the mother of all programming languages. This language is widely flexible to use memory management. C is the best option for system level programming language.
The compiler doesn't so much 'need' the break statements, it demands them.
This was a design decision. It keeps the code semantically close to C and C++ while eliminating the pitfalls of fall-through that was always a debatable 'feature' of the C languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With