Comparison of Pascal and Delphi
is a programming language devised by Niklaus Wirth in the late 1960s and early 1970s. Originally produced by Borland Software Corporation, Delphi is composed of an IDE, set of standard libraries, and a Pascal-based language commonly called either Object Pascal, Delphi Pascal, or simply 'Delphi'. Since first released, it has become the most popular commercial Pascal implementation.
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 theNested comments
Standard Pascal requires that the comment delimitersIn Delphi, however, a block comment started by
The bigramm
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.
| Standard Pascal | Delphi |
program proceduralDataType; procedure printYIntersect; begin writeLn; end; function f: real; begin f := cos; end; begin printYIntersect; end. | type TFunc = function: real; procedure printYIntersect; begin writeLn; end; function f: real; begin f := cos; end; // ─── MAIN ───────────────────────────────────────────── begin printYIntersect; end. |
Conversion of newline characters
Various computer systems show a wide variety how to indicate a newline.This affects the internal representation of
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,
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
Additional or missing features
Following features are present or missing in either language.Global goto
Standard Pascal permits a In Delphi a
label
999;
procedure foo;
begin
goto 999;
end;
begin
foo;
999: ;
end.
Buffer variables
Delphi does not support buffer variables and associated standard routinesbegin
while not EOF do
begin
output↑ := input↑;
if EOLn then
begin
writeLn;
end
else
begin
put;
end;
get;
end;
end.
Discriminated variant record allocation
In Standard Pascal allocating memory for a variantThis allows implementations to allocate the least amount of really necessary memory.
Delphi does not support this.
type
sex = ;
clothingMeasures = record
girth: real;
case gender: sex of
female: ;
male: ;
end;
var
size: clothingMeasures;
begin
new;
end.
Temporary files
In Delphi any file must be backed by a file in the file system.That means any
In contrast, Standard Pascal is usable without file names.
The following will produce a run-time error with Delphi.
var
FD: text;
begin
rewrite;
writeLn;
end.
Packing
Delphi does not implement the standard proceduresRegardless, transferring data between packed and unpacked data types is an easy feat. However, Delphi allows a class, object, or record to be declared as "packed", which minimizes the space they use.
Missing default write width
Delphi does not associate the data type Delphi demonstrates the behavior as usual for character-strings.
Overloading
Delphi permits overloading routines.In Standard Pascal identifiers must be unique in every block.
begin
result := sin;
end;
function f: real;
begin
result := cos;
end;
// ─── MAIN ─────────────────────────────────────────────
begin
// Note the different data types.
writeLn;
writeLn;
end.
Default parameter values
Delphi permits default parameters.Peculiar implementation characteristics
Standard write width
In Pascal, if the destination file is a In Delphi, for
That means always the least amount of space is occupied.
Other compilers have shown default widths of, for example,