What does the word “literal” mean?

A literal is “any notation for representing a value within source code” (wikipedia)

(Contrast this with identifiers, which refer to a value in memory.)

Examples:

  • "hey" (a string)
  • false (a boolean)
  • 3.14 (a real number)
  • [1,2,3] (a list of numbers)
  • (x) => x*x (a function)
  • /^1?$|^(11+?)\1+$/ (a regexp)

Some things that are not literals:

  • std::cout (an identifier)
  • foo = 0; (a statement)
  • 1+2 (an expression)

Leave a Comment