Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Reid G.C.Thinking in PostScript.1990.pdf
Скачиваний:
17
Добавлен:
23.08.2013
Размер:
846.44 Кб
Скачать

operators in-line versus grouped into a procedure is not particularly great. The differences amount to the ordering of operands and whether data are interleaved with instructions or pushed as a series of operands before the procedure is invoked. This difference is crucial only for readability, organization, and efficiency, and it is never required to define a procedure for good program flow.

EXPRESSING AN ALGORITHM AS A PROGRAM

If you start with a flowchart to represent an algorithm, the components of the flowchart are somewhat abstract. They represent actions and objects that are traditionally found in programming languages, and the structure and control flow of the program are represented symbolically. The use of a flowchart is predicated on the notion that the program’s algorithm can be embodied in a diagram showing the steps required to carry out the task.

Each program’s implementation is affected strongly by the language itself. Design decisions must be made based on the inherent strengths and weaknesses of the language, and the details of the implementation must ultimately be expressed using the native language constructs.

In order to represent your flowcharted algorithm as a program in some programming language, you must apply the language elements appropriately, within a structure you design. To do this, the language you are using must be fully general and must allow conditional expressions and be able to transfer control to other parts of the program. Yet each programming language was created with a particular purpose in mind, and each programming task is bent and shaped by the language in which it is implemented. The language provides the foundation. Beyond that, it is your skill as a programmer that creates a working program from the building blocks of the language. This is the art of programming.

Although it is possible to start with an abstract algorithm and then implement it in whatever programming language is handy, it is probably more realistic to assume that algorithms are developed in light of a particular language, and in such a way as to take advantage of that language’s features. For example, the kinds of data structures that exist (or are easy to implement) in a language can greatly affect the approach to solving the programming problem. PostScript has a specialized dictionary data structure that can provide entirely new approaches to problems

12

Chapter 2: POSTSCRIPT IS NOT LIKE C