ArticleslgStudy

science

Reserved word

Reserved word is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Reserved word rather than just read about it. In short: In a programming language, a reserved word (sometimes known as a reserved identifier) is a word that cannot be used by a programmer as an identifier, such as the name of a variable, function, or label – it is "reserved from use". In brief, an identifier starts with a letter, which is followed by any sequence of letters and digits (in some languages, the underscore '_' is treated as a letter).

Key takeaways

  • Reserved word belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Reserved word to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Reserved word from memory before moving on to harder problems.

Reference excerpt

In a programming language, a reserved word (sometimes known as a reserved identifier) is a word that cannot be used by a programmer as an identifier, such as the name of a variable, function, or label – it is "reserved from use". In brief, an identifier starts with a letter, which is followed by any sequence of letters and digits (in some languages, the underscore '_' is treated as a letter). In an imperative programming language and in many object-oriented programming languages, apart from assignments and subroutine calls, keywords are often used to identify a particular statement, e.g. if, while, do, for, etc. Many languages treat keywords as reserved words, including Ada, C, C++, COBOL, Java, and Pascal. The number of reserved words varies widely from one language to another: C has about 33 while COBOL has about 400. A few languages do not have any reserved words; Fortran and PL/I identify keywords by context, while Algol 60 and Algol 68 generally use stropping to distinguish keywords from programmer-defined identifiers, e.g. .if or 'if or 'if' or if is a keyword distinct from identifier if. Most programming languages have a standard library (or libraries), e.g. mathematical functions sin, cos, etc. The names provided by a library are not reserved, and can be redefined by a programmer if the library functionality is not required.

Distinction

When using an Interactive Development Environment (IDE) to develop a program, the IDE will generally highlight reserved words by displaying them in a different colour. In some IDEs, comments may also be highlighted (in yet another colour). This makes it easy for a programmer to notice unexpected use of a reserved word and/or failure to terminate a comment correctly.. There may be reserved words which are not keywords. For example, in Java, true and false are reserved words used as Boolean (logical) literals. As another example, in Pascal, div and mod are reserved words used as operators (integer division and remainder). There may also be reserved words which have no defined meaning. For example, in Java, goto and const are listed as reserved words, but are not otherwise mentioned in the Java syntax rules. A keyword such as if or while is used during syntax analysis to determine what sort of statement is being considered. Such analysis is much simpler if keywords are either reserved or stropped. Consider the complexity of using contextual analysis in Fortran 77 to distinguish:

IF (B) l1,l2 ! two-way branch, where B is a Boolean expression IF (N) l1,l2,l3 ! three-way branch, where N is a numeric expression IF (B) THEN ! start conditional block IF (B) THEN = 3.1 ! conditional assignment to variable THEN IF (B) X = 10 ! single conditional statement IF (B) GOTO l4 ! conditional jump IF (N) = 2 ! assignment to a subscripted variable named IF

PL/I can also allow some apparently confusing constructions:

IF IF = THEN THEN ... /* (the second IF and the first THEN are variables */

Advantages

Programs may be more readable as compared with a programming language which uses stropping. It is easier for an IDE to highlight keywords, without having to do a contextual analysis to determine which words are actually keywords (see Fortran examples in previous section). A compiler can be faster, since it can quickly determine if a word is a keyword, without having to do a contextual analysis over the whole of an arbitrarily long statement.

Disadvantages

A programming language may be difficult for new users to learn because of a (possibly long) list of reserved words to memorize which can't be used as identifiers. It may be difficult to extend the language because addition of reserved words for new features might invalidate existing programs or, conversely, "overloading" of existing reserved words with new meanings can be confusing. Porting programs can be problematic because a word not reserved by one system or compiler might be reserved by another.

Further reservation Beyond reserving specific lists of words, some languages reserve entire ranges of words, for use as private spaces for future language version, different dialects, compiler vendor-specific extensions, or for internal use by a compiler, notably in name mangling. This is most often done by using a prefix, often one or more underscores. C and C++ are notable in this respect: C99 reserves identifiers that start with two underscores or an underscore followed by an uppercase letter, and further reserves identifiers that start with a single underscore (in the ordinary and tag spaces) for use in file scope; with C++03 further reserves identifiers that contain a double underscore anywhere – this allows the use of a double underscore as a separator (to connect user identifiers), for instance. The frequent use of double underscores in internal identifiers in Python gave rise to the abbreviation dunder; this was coined by Mark Jackson and independently by Tim Hochberg, within minutes of each other, both in reply to the same question in 2002.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Reserved word

Start with the simplest possible case. Write down what Reserved word claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Reserved word before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Reserved word ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Reserved word

In research
Reserved word appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Reserved word in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Reserved word is common in secondary-school and first-year university syllabi. It links to neighbouring topics Programming constructs, Programming language topics, so understanding it makes those chapters shorter.
In everyday life
Look for Reserved word outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Reserved word” →

How to study Reserved word in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Reserved word means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Reserved word out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Reserved word in simple terms?

In a programming language, a reserved word (sometimes known as a reserved identifier) is a word that cannot be used by a programmer as an identifier, such as the name of a variable, function, or label – it is "reserved from use". In brief, an identifier starts with a letter, which is followed by an…

Why does Reserved word matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Reserved word?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Reserved word.

Tags

  • Programming constructs
  • Programming language topics

Keep exploring