Differences between Smart Pascal and Free Pascal (Lazarus)

We have positioned towards the beginning of the table a few syntax differences that beginners are likely to encounter. More experienced programmers will be interested in the more general fundamental differences that follow.

Table 1. Some Differences between Smart Pascal and Free Pascal
Language feature Free Pascal/Lazarus Smart Pascal
Array constants

Round brackets

Square or round brackets
Type inference none var MyInt = 15;
In-line variable declarations not possible for var i := 1 to 3 do


(You can also declare a variable within begin/end blocks).

Char variable

var
  MyChar: char;

No char variable type. Use a string to represent a single character.
Dynamic array

Widely used, but no inbuilt routines

Powerful, with inbuilt routines such as Push (to add an element to the end), Pop (to remove the last element), Clear, Copy, Delete, IndexOf, Swap and Reverse
Random MyRandomInt := Random(10); MyRandomInt := RandomInt(10);
writeln Takes multiple arguments of different types e.g.


writeln(‘Answer: ’, MyInt);

Takes one string e.g.


Console.Writeln(‘Answer: ’ + intToStr(MyInt));

Field widths and display of reals Writeln(MyReal : 6 : 2) not possible
Input key codes ASCII

JavaScript (Some are the same as ASCII).

Asm block Assembler
asm
  ADD Int1, 5
  SUB Int2, 30 
end;
JavaScript
asm
  document.location.href="http://www.pp4s.co.uk/";
end;
Sets Lots of functionality Limited functionality
Pointers See use of pointers in linked lists No pointers
File handling Easy to write and read local files Very different: see Storing and Loading Data
Graphics Several approaches including Canvas, Graph or WinGraph and SDL Very different, using HTML5 Canvas
Generics Generics no generics
List of Objects TList TObjectList
Programming - a skill for life!

Developing graphical web pages including 3D, input from keyboard and mouse and storing and loading data