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

COMPARISON OF LANGUAGE MECHANISMS

 

One of the first skills a programmer develops is the ability to

 

conceptualize the procedures that will be needed for a program to be

 

implemented effectively. These procedures are designed by deciding what

 

data are needed, how that data ought to be passed through the control

 

sequence of the program, and how the naming of the procedures will

 

contribute to the readability and flow of the program. Procedures should

 

not be too big and complex, nor too small and inefficient.

 

There is a major difference between PostScript and C that makes program

 

design completely different. In C, you basically have no built-in language

 

elements. There are a few control structures, loop constructs, some

 

input/output operations, and the inherent procedure call mechanism, but

 

there aren’t a lot of individual operators as there are in PostScript. In a

 

sense, the entire program design is based on the implementation of

 

procedures or modules.

 

In PostScript program design, almost the opposite is true. There are well

 

over 300 individual PostScript operators. Very efficient, well-designed

 

programs can be constructed without ever writing a single procedure, just

 

by using the built-in operators. Then, when the functionality of the

 

program fully emerges, the ability to define procedures can help you to

 

organize the code or to make it more efficient, but usually it is not a good

 

approach to begin by designing the procedures themselves, since the work

 

is ultimately carried out by the individual operators anyway.

 

 

 

 

TIP

A PostScript procedure is simply a set of operations that are grouped

 

together and that can be invoked by a single instruction. They do not

 

replace the individual operations, they merely provide another way to

 

cause them to be executed. The principle advantages to defining

 

procedures is to collect sequences of operations that may be performed

 

repeatedly.

 

 

 

 

 

Furthermore, the operand stack is the communication area between

 

procedures; it is the only place where you can pass data between

 

procedures. But, since this is also the way data are passed to individual

 

PostScript operators, the distinction between a sequence of PostScript

Chapter 2: POSTSCRIPT IS NOT LIKE C

11