Literals



next up previous contents index
Next: Identifiers that denote Up: Expressions Previous: Expressions

Literals

Literals denote objects of the built-in types "int", "real", "char", "string", "bool", and "null". The type of a literal expression is the type of the object named by the literal. Some examples of literals being assigned to variables are:

t:      bool    := true
f:      bool    := false
s:      string  := "A string"
c:      char    := 'c'
nl:     char    := '\n'         % newline
oct47:  int     := 8_47         % octal integer
hex7e:  int     := 16_7e        % hexadecimal integer 
p:      int     := -5 
pi:     real    := 3.141592
avog:   real    := 6.02e23
empty:  null    := nil

The full syntax for literals is given in Appendix B.



theta-questions@lcs.mit.edu