program Foo (Input, Output);
begin
end.
In GNU Pascal, headline parameters are optional. If the headline is omitted entirely, a warning is given unless you have specified --borland-pascal in the command line.
otherwise (according to Extended Pascal) as an
alternative to else:
program CaseOtherwiseDemo;
var x: Integer;
begin
ReadLn (x);
case x of
1: WriteLn ('one');
2: WriteLn ('two');
otherwise
WriteLn ('many')
end
end.
Note: In the absence of a case or otherwise branch, missing cases labels cause an error in Extended Pascal (which goes unnoticed in Borland Pascal). GPC does not give this error, but a warning if the -Wswitch option is given, however only for enumeration types.
Card function for sets which counts
their elements. Unlike Borland Pascal, GNU Pascal does not limit
sets to the range 0 .. 255.
Borland Pascal:
function Max (x, y: Integer): Integer;
inline ($58 / $59 / $3b / $c1 / $7f / $01 / $91);
GNU Pascal:
program InlineDemo;
function Max (x, y: Integer): Integer; attribute (inline);
begin
if x > y then
Max := x
else
Max := y
end;
begin
WriteLn (Max (42, 17), ' ', Max (-4, -2))
end.
(Actually, a more general Max function is already built in.)
This feature is not so important as it might seem because in optimization level 3 or higher (see GPC Options), GNU Pascal automatically inlines short procedures and functions.