The table in this document is intended to document the syntactic support between various Pascal compilers. The rationale of this document is to help choose the most portable syntax. In the future, m4 or sed will probably be used to get around the differences.
The origin column documents the first standard — Standard Pascal, Extended Pascal or Object Pascal — to include the feature. If the feature hasn't been included in any standard, then the first compiler — UCSD Pascal (1977–1981), Apple Pascal (1979–1998), Turbo Pascal (1984–1993), GNU Pascal (1988–2007), Delphi (1994–2003), Free Pascal (1996–) or Delphi.NET (2003–) — known to have implemented the non-standard extension will be indicated. pre-standard Pascal means that the feature was proposed by Pascal creator Niklaus Wirth, but wasn't integrated into any of the standards and hasn't been implemented by any known compiler.
For more compiler differences, you might want to check out Apple and Borland Pascals Compared, though it's outdated; that is, Turbo Pascal and Apple Pascal have both been discontinued, and the only living compilers for the Macintosh are Free Pascal and GNU Pascal, both of which are Borland compatible with a few of the Apple synonyms (as Cycle
in addition to Continue
) implemented.
Also note that not all of Free Pascal and GNU Pascal features are always enabled. For example, in Free Pascal, -Sg enables spaghetti code, -Mobjpas enables Object Pascal, -Mmacpas enables mode MacPas, etc. Similarly, using --extended-pascal in GNU Pascal allows only Extended Pascal, --classic-pascal allows only Standard Pascal, etc. In Free Pascal, you can use the fpc.cfg file to always have the features you want enabled and those that you don't disabled.
Feature | Free Pascal 2.6.0 | GNU Pascal 20070904 | Delphi 7 | Origin |
---|---|---|---|---|
{ Comments } | yes | yes | yes | Standard Pascal |
{$DEFINE ...} | yes | yes | yes | UCSD Pascal |
{$ELIF ...} | no | yes | no | GNU Pascal |
{$ELSEIF ...} | yes | no | yes | Delphi |
{$ENDIF ...} | yes | yes | yes | UCSD Pascal |
{$IF ...} | yes | yes | yes | UCSD Pascal |
{$IFDEF ...} | yes | yes | yes | UCSD Pascal |
{$IFNDEF ...} | yes | yes | yes | UCSD Pascal |
{$LINK object-file} | yes | yes | yes | UCSD Pascal |
{$UNDEF ...} | yes | yes | yes | UCSD Pascal |
(*...*) (This is an avoidable replacement for the brace characters to be used only when the braces can't be used (a remote possibility, due to keyboard remapping)) | yes | yes | yes | Standard Pascal |
@ (pointer address) | yes | yes | yes | Standard Pascal |
#number (code point in the current character set; synonym: Chr) | yes | yes | yes | Apple Pascal |
^ (pointer allocator) | yes | yes | yes | Standard Pascal |
^ (pointer deallocator) | yes | yes | yes | Standard Pascal |
> | yes | yes | yes | Standard Pascal |
< | yes | yes | yes | Standard Pascal |
<> | yes | yes | yes | Standard Pascal |
+ (numbers) | yes | yes | yes | Standard Pascal |
+ (strings) | yes | yes | yes | Extended Pascal |
- | yes | yes | yes | Standard Pascal |
/ | yes | yes | yes | Standard Pascal |
* | yes | yes | yes | Standard Pascal |
** (to the real power of) | yes | yes | no | Extended Pascal |
= | yes | yes | yes | Standard Pascal |
. (access a record, object or class field) | yes | yes | yes | Standard Pascal |
. (access an identifier from conflicting units or modules; e.g.: SysUtils.GetSystemTime and Windows.GetSystemTime) | yes | yes | yes | Turbo Pascal |
'String' | yes | yes | yes | Standard Pascal |
"String with escapes\/special characters\n" | no | yes | no | GNU Pascal |
abstract (method directive) | yes | yes | yes | Object Pascal |
abstract class | no | yes | no | Object Pascal |
and | yes | yes | yes | Standard Pascal |
Append(file-type) | yes | yes | yes | Turbo Pascal |
array[x..y] of data-type | yes | yes | yes | Standard Pascal |
array[x..y: data-type] of data-type (conformant arrays) | no | yes | no | Standard Pascal (optional feature) |
array of data-type (dynamic arrays) | yes | no | yes | Delphi |
array of data-type (open arrays) | yes | yes | yes | Turbo Pascal |
array of const (mixed open arrays) | yes | no | yes | Delphi |
Assign(var file-type; file-name) | yes | yes | yes | Turbo Pascal |
Assigned(pointer) | yes | yes | yes | Turbo Pascal |
attribute(attributes) | no | yes | no | GNU Pascal |
begin (beginning of block) | yes | yes | yes | Standard Pascal |
Boolean | yes | yes | yes | Standard Pascal |
Break | yes | yes | yes | Turbo Pascal |
cardinal | yes | yes | yes | Turbo Pascal |
case var of ... end; | yes | yes | yes | Standard Pascal |
case ... else | yes | yes | yes | Turbo Pascal |
case ... otherwise | yes | yes | no | Extended Pascal |
Chr(code-point) (seldom-used synonym for #code-point) | yes | yes | yes | Standard Pascal |
class | yes | yes | yes | Object Pascal |
Classes unit | yes | no | yes | Delphi |
Close(file-type) | yes | yes | yes | UCSD Pascal |
const const-name = const-value; ... | yes | yes | yes | Standard Pascal |
const const-name: data-type = const-value; ... | yes | yes | yes | Apple Pascal |
const parameters | yes | yes | yes | Turbo Pascal |
constructor | yes | yes | yes | Object Pascal |
Continue | yes | yes | yes | Turbo Pascal |
Crt unit | yes | yes | yes | Turbo Pascal |
CString (a more semantically clear synonym of PChar) | no | yes | no | GNU Pascal |
Cycle | yes | yes | no | Apple Pascal |
data-type(variable) (type casting) | yes | yes | yes | Turbo Pascal |
data-type = [func-decl | proc-decl] (procedural type) | yes | yes | yes | Turbo Pascal |
destructor | yes | yes | yes | Object Pascal |
Dispose(typed-pointer) | yes | yes | yes | Standard Pascal |
Dispose(typed-pointer, object-deconstructor) | yes | yes | yes | Apple Pascal |
div | yes | yes | yes | Standard Pascal |
end; (end of statement list) | yes | yes | yes | Standard Pascal |
end. (end of source file) | yes | yes | yes | Standard Pascal |
(enum-const, ...) (enumerated type) | yes | yes | yes | Standard Pascal |
enum-const := value | yes | no | no | Free Pascal |
enum-const = value | yes | no | yes | Delphi |
Eof(file-type) | yes | yes | yes | Standard Pascal |
Exit | yes | yes | yes | UCSD Pascal |
exports ...; | yes | no | yes | Delphi |
external | yes | yes | yes | UCSD Pascal |
false | yes | yes | yes | Standard Pascal |
for counter := start to | downto end do ... | yes | yes | yes | Standard Pascal |
for counter := start to | downto end by rate do ... | no | no | no | pre-standard Pascal |
Free method | yes | no | yes | Delphi |
function func-name[(params)]: return-type; | yes | yes | yes | Standard Pascal |
func-name | proc-name [(params)] (calling subroutines) | yes | yes | yes | Standard Pascal |
goto | yes | yes | yes | Standard Pascal |
if condition then ... [else [if condition then] ...]+ | yes | yes | yes | Standard Pascal |
import module1;[ module2;[...]] | no | yes | no | Extended Pascal |
Index(str, substr) | no | yes | no | Extended Pascal |
inherited | yes | yes | yes | Object Pascal |
integer | yes | yes | yes | Standard Pascal |
interface (abstract class) | yes | no | yes | Delphi |
is | yes | yes | yes | Object Pascal |
Keyboard unit | yes | no | yes | Turbo Pascal |
label | yes | yes | yes | Standard Pascal |
Leave | yes | yes | no | Apple Pascal |
Length(string) | yes | yes | yes | Extended Pascal |
Length(array) | yes | no | yes | Delphi |
library libname; | yes | no | yes | Delphi |
LowerCase(str) | yes | yes (in SysUtils) | yes | Turbo Pascal |
module mod-name[ interface | implementation]; | no | yes | no | Extended Pascal |
module ... export | no | yes | no | Extended Pascal |
New(typed-pointer) | yes | yes | yes | Standard Pascal |
New(typed-pointer, object-constructor) | yes | yes | yes | Apple Pascal |
New(typed-pointer, variant-record) | no | yes | no | Standard Pascal |
not | yes | yes | yes | Standard Pascal |
nil | yes | yes | yes | Standard Pascal |
object | yes | yes | yes | Apple Pascal |
Objects unit | yes | yes (separate download) | yes | Turbo Pascal |
of object | yes | no | yes | Delphi |
on [variable: ]exception-class do ... | yes | no | yes | Delphi |
or | yes | yes | yes | Standard Pascal |
override | yes | yes | yes | Object Pascal |
PChar (access to C's "char *") | yes | yes | yes | Turbo Pascal |
Pointer | yes | yes | yes | Turbo Pascal |
Pos(substr, str) | yes | yes | yes | UCSD Pascal |
private | yes | yes | yes | Object Pascal |
procedure proc-name[(params)]; | yes | yes | yes | Standard Pascal |
program progname [(io-handles)]; | yes | yes | yes | Standard Pascal |
protected | yes | yes | yes | Object Pascal |
property var-name: var-type[ read var-name | zero-param-func-name][ write var-name | one-param-proc-name]; | yes | no | yes | Delphi |
property class | no | no | no | Object Pascal |
PtrInt | yes | yes | no | GNU Pascal |
PtrUInt (same as PtrWord) | yes | no | no | Free Pascal |
PtrWord (same as PtrUInt) | no | yes | no | GNU Pascal |
public | yes | yes | yes | Object Pascal |
published | yes | yes | yes | Delphi |
ReadLn(in-str) (read from standard in) | yes | yes | yes | UCSD Pascal |
ReadLn(file-type, in-str) (read from a file) | yes | yes | yes | Standard Pascal |
ReadStr(format, buffer) | yes | yes | no | Extended Pascal |
record variable-definitions end; | yes | yes | yes | Standard Pascal |
record ... case data-type of ... end; (variant record) | yes | yes | yes | Standard Pascal |
repeat ... until | yes | yes | yes | Standard Pascal |
resourcestring | yes | no | yes | Delphi |
Reset(file-type) | yes | yes | yes | Standard Pascal |
Result | yes | yes | yes | Delphi |
Rewrite(file-type) | yes | yes | yes | Standard Pascal |
Root | no | no | no | Object Pascal |
set of data-type; | yes | yes | yes | Standard Pascal |
Str(input-number; var output-string) | yes | yes | yes | UCSD Pascal |
String (data type) | yes | yes | yes | UCSD Pascal |
String(max-len) (schema type) | no | yes | no | Extended Pascal |
SysUtils unit | yes | yes (separate download) | yes | Delphi |
TList | yes | no | yes | Delphi |
TObject (class) | yes | no | yes | Delphi |
TObject (object) | yes | yes (in Objects) | yes | Apple Pascal |
TranslateResourcestrings (path-templ) | yes | no | no | Free Pascal |
Trim(str) | yes | yes | yes | Extended Pascal |
true | yes | yes | yes | Standard Pascal |
try ... except ... end; | yes | no | yes | Delphi |
try ... finally ... end; | yes | no | yes | Delphi |
try ... except ... finally ... end; | no | no | no | Delphi.NET? |
TStringList | yes | no | yes | Delphi |
type user-defined-types | yes | yes | yes | Standard Pascal |
type pointer-type = ^non-pointer-type | yes | yes | yes | Standard Pascal |
unit unit-name; | yes | yes | yes | UCSD Pascal |
unit ... interface ... | yes | yes | yes | UCSD Pascal |
unit ... implementation ... | yes | yes | yes | UCSD Pascal |
UpCase(str) | yes | yes (in SysUtils) | yes | Turbo Pascal |
uses unit1[, unit2[,...]]; | yes | yes | yes | UCSD Pascal |
Val(in-string; var out-num, out-err) | yes | yes | yes | Turbo Pascal |
value | no | yes | no | Extended Pascal |
var var-name: var-type; ... | yes | yes | yes | Standard Pascal |
(var var-name: var-type) (variable parameters) | yes | yes | yes | Standard Pascal |
(var var-name) (untyped variable parameters) | yes | yes | yes | UCSD Pascal |
var-name: var-type = var-value (inline initialized variables) | yes | yes | yes | Delphi |
var-name: var-type = var-value (default parameters) | yes | no | yes | Delphi |
var-name := var-value; | yes | yes | yes | Standard Pascal |
view of class | no | yes | no | Object Pascal |
virtual (makes a method belong to the constructed class, not the declared class; note: not in Object Pascal or Apple Pascal, because in those dialects, methods are always virtual) | yes | yes | yes | Turbo Pascal |
while condition do ... | yes | yes | yes | Standard Pascal |
with rec-var | obj-var | class-var do | yes | yes | yes | Standard Pascal |
WriteLn(output-string) (writing to standard out) | yes | yes | yes | Standard Pascal |
WriteLn(file-type, output-string) (writing to a file) | yes | yes | yes | Standard Pascal |
WriteStr(buffer-string, format) | yes | yes | no | Extended Pascal |
xor | yes | yes | yes | Standard Pascal |