8.3 String constants


Besides structures, another kind of term is the string constant. A string constant is a sequence of characters enclosed in double quotes.


For example, the following are all string constants:

  • "This is a string"
  • "Humpty Dumpty sat on a wall"
  • "Albert"
  • "Niels"
  • "froobjoob gargle barg"
  • "'123' is my favorite number"
  • "What insolence! She slammed the door in my face!"

Double quotes can't be included in a string

The string constant starts and ends with a double quote. That gives rise to a problem: Can one include a double quote in a string? If we include a double quote, Prolog+CG will assume that the string is finished. Unfortunately, there is no way to include a double quote in a string in the present version of Prolog+CG.


Thus string constants are one kind of term, they are sequences of characters enclosed in double quotes, and there is no way to include a double quote in a string.


We have treated two kinds of terms: Structures and string constants. Next, we treat another kind of term, namely atomic constants. We have already briefly touched upon this when we said that atoms were structures with arity 0. Now we treat them more fully.

PrevLite: 8.2 Structures
NextLite: 8.4 Atomic constants

Prev: 8.2 Structures
Up: 8 Terms
Next: 8.4 Atomic constants