The definition of PASCAL is, above all else, intended to be simple. PASCAL was designed as a pedagogical language (with aspirations to be useful for commercial purposes, but that was a secondary concern). For this purpose, the definition had to be small and orthogonal so that it could be explained simply and concisely. For ease of implementation, the number of special cases had to be kept to a minimum.
The boolean type is handled by the system as simply an example of an enumerated type. It is effectively equivalent to having a definition
type boolean = (false, true)
automatically included in the program. Specficially: it can be implemented by entering false
and true
into the symbol table with associated type of boolean
. They can then never be used for any other type, as PASCAL identifiers are associated with a single type only in any scope.
nil
, however, could not be defined by an existing language mechanism. The language simply does not provide any means of creating a pointer value other than via new
, which creates a value while nil
refers to an absence of value. Therefore, a new language feature was required to implement it, so a new keyword was added for that feature.
Also, nil
does not behave the same way an identifier does: it does not have a predetermined type. The type of a nil
expression is determined by its context -- it may become any type pointer that is required to make the expression type check. If it were implemented as an identifier rather than a keyword, that would have required a special case for polymorphic identifiers, of which only a single instance was required for the language and no way provided of defining new ones: clearly not a useful way of approaching the problem.
NIL
could be a function that would return different values over time.PROCEDURE
andFUNCTION
for every function - in C there is no keyword for this, it is obvious and defined by the context.PROCEDURE
andFUNCTION
keywords: Pascal's syntax is largely a result of the first Pascal compiler being recursive descent. For that, you have to be able to tell what you're parsing with only one token of lookahead.