Range Over Iterators in Pascal

Our first program will print the classic “hello world” message. Here’s the full source code.

program HelloWorld;
begin
  writeln('hello world');
end.

To run the program, save the code in a file named HelloWorld.pas and use a Free Pascal Compiler (FPC) to compile and run it.

$ fpc HelloWorld.pas
$ ./HelloWorld
hello world

Sometimes we’ll want to compile our programs into executables. Here’s how to do it with Free Pascal Compiler:

First, compile the code:

$ fpc HelloWorld.pas
$ ls
HelloWorld       HelloWorld.pas    HelloWorld.o

We can then execute the binary directly.

$ ./HelloWorld
hello world

Now that we can run and build basic Pascal programs, let’s learn more about the language.