Concept

Constant

Modified just now
Books JourneyProgramming Language Theory Statusmastered Tags
  • compiler implementation
  • language-feature-design
  • program analysis
  • semantics
  • syntax grammar

The token itself is the value-the parser can extract it directly without consulting any environment or performing computation

  • Requires no evaluation or name lookup.
  • Examples: 42, "hello", true, 3.14.
  • Also called: Literal, self-evaluating expression.

INFO

(Semantics, Semantics, Language feature/design, Program analysis) (a.k.a semantic constant) A declaration that restricts mutability of a binding and/or its value.

  • Constant binding: Name cannot be reassigned to a different reference (JavaScript const, Java final).
  • Constant value: The underlying data cannot be modified (C++ const, Rust default).
  • Some languages enforce both; others only one.