Lably
Skip to content

Comparison of Pascal and Delphi

Programming language

  • 7 min read
  • 3 chapters

Related on Lably

Through Modulo

While developing Pascal, Wirth employed a bootstrapping procedure in which each newer version of the Pascal compiler was written and compiled with its predecessor. Thus, the 'P2' compiler was written in the dialect compilable by 'P1', 'P3' in turn was written in 'P2' and so on, all the way till 'P5'. The 'P5' compiler implemented Pascal in its final state as defined by Wirth, and subsequently became standardised as 'ISO 7185 Pascal'.

The Borland dialect, like the popular UCSD Pascal before it, took the 'P4' version of the language as its basis, rather than Wirth's final revision. After much evolution independent of Standard Pascal, the Borland variant became the basis for Delphi. This page goes over the differences between Delphi and Standard Pascal. It does not go into Delphi-specific extensions to the language, which are numerous and still increasing.

Exclusive features

Following features are mutually exclusive. The Standard Pascal implementation is not accepted by Delphi and vice versa, the Delphi code is not acceptable in Standard Pascal.

Modulo with negative dividend

Standard Pascal has a Euclidean-like definition of the mod operator whereas Delphi uses a truncated definition.

Nested comments

Standard Pascal requires that the comment delimiters { and the bigram (*, as well as } and *) are synonymous to each other. In Delphi, however, a block comment started by { must be closed with a }. The bigramm *) will only close any comment that started with (*. This scheme allows for nested comments.

Procedural data types

The way procedures and functions can be passed as parameters differs: Delphi requires explicit procedural types to be declared where Standard Pascal does not.

Conversion of newline characters

Various computer systems show a wide variety how to indicate a newline. This affects the internal representation of text files which are composed of a series of “lines”. In order to relieve the programmer from any associated headaches, Standard Pascal mandates that reading an “end-of-line character” returns a single space character. To distinguish such an “end-of-line” space character from a space character that is actually genuine payload of the line, EOLn becomes true.

Delphi does not show this behavior. Reading a newline will return whatever character sequence represents a newline on the current host system, for example two char values chr(13) (carriage return) plus chr(10) (line feed).

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication