What's the difference between a sentence and a noun that starts a sentence? ;-)
return
is a keyword, which means it's one of a few basic terms (tokens) of the language. They are privileged, each reserved for a special purpose and having special meaning (compare this with run of the mill identifiers/names).
A statement is (in broad terms - specific differ between languages) a higher-level unit of the language, akin to (a particular kind of) sentence in natural language. Statements include return 1+1;
and foo(bar);
, but generally not expressions like 1+1
or foo(bar)
.
Keywords often form part of statements (e.g. return
introduces a return statement), but they never make a full statement on their own - even return;
still needs a statement terminator.
C developed and become very popular before it was planned by a standards committee. In consequence, there was a lot of existing code.
When setting a C standard, or updating an old standard, an important goal is not to “break” old code. It is desirable that code that worked with previous compilers continue to work with new versions of the C language.
Introducing a new keyword (or any new definition or meaning of a word) can break old code, since, when compiling, the word will have its new keyword meaning and not the identifier meaning it had with the previous compilers. The code will have to be edited. In addition to the expense of paying people to edit the code, this has a risk of introducing bugs if any mistakes are made.
To deal with this, a rule was made that identifiers starting with underscore were reserved. Making this rule did not break much old software, since most people writing software choose to use identifiers beginning with letters, not underscore. This rule gives the C standard a new ability: By using underscore when adding new keywords or other new meanings for words, it is able to do so without breaking old code, as long as that old code obeyed the rule. For example, adding a new keyword, _Bool
for a Boolean type, would not break any code that had not used identifiers beginning with an underscore.
New versions of the C standard sometimes introduce new meanings for words that do not begin with an underscore, such as bool
. However, these new meanings are generally not introduced in the core language. Rather, they are introduced only in new headers. In making a bool
type, the C standard provided a new header, <stdbool.h>
. Since old code could not be including <stdbool.h>
since it did not exist when the code was written, defining bool
in <stdbool.h>
would not break old code. At the same time, it gives programmers writing new code the ability to use the new bool
feature by including <stdbool.h>
, which defines bool
as a macro that is replaced by _Bool
.
Best Answer
It's not necessary -- Fortran didn't reserve any words, so things like:
are complete legal. This not only makes the language hard for the compiler to parse, but often almost impossible for a person to read or spot errors. for example, consider classic Fortran (say, up through Fortran 77 -- I haven't used it recently, but at least hope they've fixed a few things like this in more recent standards). A Fortran DO loop looks like this:
Without them being side-by-side, you can probably see how you'd miss how this was different:
Unfortunately, the latter isn't a DO loop at all -- it's a simple assignment of the value
1.10
to a variable namedDO 10 I
(yes, it also allows spaces in a name). Since Fortran also supports implicit (undeclared) variables, this is (or was) all perfectly legal, and some compilers would even accept it without a warning!