Книга: Introduction to Microprocessors and Microcontrollers

Pascal

Pascal

Pascal was first designed in Switzerland in 1971 (Figure 10.7). It is mostly an academic language and has been largely overtaken for professional programming by languages such as C. When learning other languages, a short course of Pascal is often employed as an introduction. Pascal is used because it is ‘good for you’, just as it is often said that to learn European languages it is ‘good’ to learn Latin first to lay down the rules of language before starting on French, German or Spanish.


Figure 10.7 Pascal does you good

Pascal is a very structured language. A structured program consists of a series of separate, self-contained units each having a single starting point and a single exit point. The program layout looks like a simple block diagram with all the blocks arranged one under the other. Since every unit can be isolated from the ones above and below, detecting an error, or understanding a new program, is relatively easy.

Languages like Basic can use instructions like GO TO to jump to a new part of the program and this often results in what is called ‘spaghetti’ programming, making it very difficult to find a fault in the program or even to understand what the program does (see Figure 10.8). Pascal avoids this by using instructions like ‘Repeat…until’. Basic is cleaning up its act by incorporating this type of instruction into the more recent versions.


Figure 10.8 Structure and spaghetti

Оглавление книги


Генерация: 0.165. Запросов К БД/Cache: 2 / 0
поделиться
Вверх Вниз