# Pascal’s Achilles Heel

The Pascal programming language was designed for teaching. Anyone who learned programming in the 1970s and 80s likey did so using Pascal. One of the main idiosyncrasies with the design of Pascal is the use of semicolons. In C, semicolons perform the task of terminating statements, so it is hard to use them in the wrong context. In Pascal, semicolons are statement separators adopted from the syntax of ALGOL. This basically means that they do not exist in places where the layout of the program would make them redundant. For example, consider this piece of code in C:

```1 while (!odd(y))
2 {
3    y = y / 2;
4    x = sqrt(x);
5 }```

whereas in Pascal the code would look like this:

```1 while not odd(y) do
2 begin
3    y := y div 2;
4    x := sqr(x)
5 end;```

The two statements on lines 3 and 4 are separated by a semicolon. The semicolon after the end on line 5 separates the while loop from the next statement. Most Pascal compilers will also accept the following:

```1 while not odd(y) do
2 begin
3    y := y div 2;
4    x := sqr(x);
5 end;```

But failure to add the semicolon at the end of line 5, as in:

```1 while not odd(y) do
2 begin
3    y := y div 2;
4    x := sqr(x);
5 end
6 y := y - 1;
7 z := x * z;```

This will result in an an error of the form:

```Fatal: Syntax error, ";" expected but "identifier Y" found
Fatal: Compilation aborted```

Similarly, a semicolon before an else statement will effectively chop the if statement in two, causing an error. The following is the correct way:

```if i > j
then maxi := i
else maxi := j;```

Basically if you are writing programs in Pascal, remember the following two rules:
a semicolon before ELSE is wrong;
a semicolon before END is unnecessary.