The characters space, tab, newline, and return are called
whitespace characters. Whitespace is used as necessary to separate
lexical symbols, such as integers, identifiers, or keywords. For example
Thorondor is a single identifier, while Th or ondor is the keyword
or between the two identifiers Th and ondor. Whitespace may occur
between any two symbols, but not within a symbol. Two or more adjacent
whitespace characters are equivalent to a single whitespace.
Apart from the role as separator of symbols,
whitespace characters are otherwise insignificant.
Whitespace characters may also occur inside a string,
where they are significant.
Whitespace characters should also be used freely for improved readability.
A comment starts with the character #, which is sometimes called
sharp or hatch, and continues to the end of the line on which the comment
character appears. The whole comment, including # and the newline
character is treated as a single whitespace. Inside a string, the
comment character # loses its role and is just an ordinary character.
For example, the following statement
if i<0 then a:=-i;else a:=i;fi;
is equivalent to
if i < 0 then # if i is negative a := -i; # take its additive inverse else # otherwise a := i; # take itself fi;
(which by the way shows that it is possible to write superfluous comments). However the first statement is not equivalent to
ifi<0thena:=-i;elsea:=i;fi;
since the keyword if must be separated from the identifier i by a
whitespace, and similarly then and a, and else and a must be
separated.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual