Next: Utilities and units that
Up: Porting Turbo Pascal Code
Previous: Things which are extra
When you compile a program with the -So switch, the compiler will
attempt to mimic the Turbo Pascal compiler in the following ways:
- Assigning a procedural variable doesn't require a @ operator. One of
the differences between Turbo Pascal and Free Pascal is that the latter requires
you to specify an address operator when assigning a value to a procedural
variable. In Turbo Pascal compatibility mode, this is not required.
- Procedure overloading is disabled.
- Forward defined procedures don't need the full parameter list when
they are defined. Due to the procedure overloading feature of Free Pascal, you must
always specify the parameter list of a function when you define it, even
when it was declared earlier with Forward. In Turbo Pascal
compatibility mode, there is no function overloading, hence you can omit the
parameter list:
Procedure a (L : Longint); Forward;
...
Procedure a ; { No need to repeat the (L : Longint) }
begin
...
end;
- recursive function calls are handled dfferently. Consider the
following example :
Function expr : Longint;
begin
...
Expr:=L:
Writeln (Expr);
...
end;
In Turbo Pascal compatibility mode, the function will be called recursively
when the writeln statement is processed. In Free Pascal, the function result
will be printed. In order to call the function recusively under Free Pascal, you
need to implement it as follows :
Function expr : Longint;
begin
...
Expr:=L:
Writeln (Expr());
...
end;
- Any text after the final End. statement is ignored. Normally,
this text is processed too.
- You cannot assign procedural variables to void pointers.
- The @ operator is typed when applied on procedures.
- You cannot nest comments.
Michael Van Canneyt
Thu Sep 10 13:56:17 CEST 1998