Postscript
}} | date = | typing = dynamic, strong | implementations = Adobe PostScript, TrueImage, Ghostscript | dialects = | influenced by = Forth | = pdf influenced | operating system = | license = | Web site = }} |- | |}
The PostScript is a data-processing Langage specialized in the description of page, developped at the point by Adobe. It rests on vectorial formulations of the majority of its elements. It can also treat the images in the form of bitmap or raster (group of dots).
This language inter-platforms makes it possible to obtain a single file comprising all the elements describing page (texts, images, police forces, colors, etc).
PostScript became practically a standard, the majority of the recent printers can treat directly the format PostScript (NB: on the older printers, it was necessary to use a software filter in entry for to convert the PostScript language with the comprehensible format raster by the old printers).
Other kids of PostScript are
- Display PostScript and NeWS, both concerning the systems of fenestration.
- EPS (for Encapsulated PostScript), format of image, based on PostScript
The language
Postscript is a complete language, which allows the coding of all algorithm. Although it is completely possible to write such programs directly, they are in general manufactured by other programs, pilots of impression for example.
Postscript is indissociable environment in which it will be carried out. Being given the completely dynamic character of this language, it will be in fact interpreted.
The interpreter is composed of a pile, and one or more dictionaries. The pile is used as temporary storage for the parameters of the functions, then for their results. The dictionaries allow the storage of the variables, as well as code of the functions.
A PostScript program is composed of a sequence of words separated by spaces, tabulation (TAB), Carriage return (CR), advances line (LF), or comments. The interpreter analyzes each word of the PostScript program sequentially while functioning like a calculator in Polish Notation reverses, i.e. each word is evaluated, then it (or them) result of this evaluation is placed at the top of the pile, and so on.
Example, to carry out simple numerical calculation B - 4 ac , that will be able to be coded:
-
b B mul 4 has mul C mul sub
PostScript supports five types of words:
- constant numerical whole or real:
123or3.14157, the evaluation adds the numerical value to the top of the pile; - constant chain: they are tables of natures framed by brackets, ex
(ABC)represents the chain “ABC”; - reference to a name:
/arepresents the name “has”, which will be able to make it possible to name a variable or a function; the reference is added to the top of the pile; - name: it can be the name of a procedure preset or created, a variable, a dictionary; the name is sought in the active dictionaries, then if it is a value, it is placed on the pile, and if it is a function, it is called (carried out); to note that the evaluation of a function could use the values at the top of the pile and to replace them by the possible results;
- manufacturer: four manufacturers allow to create structures of data of variable size, they are composed of following paired natures, which delimit the beginning and the end of the structure:
-
and: unspecified tables. -
<and>: tables of bytes coded into hexadecimal. -
< <and> >: dictionaries. -
{and}: achievable code.
The dictionaries are tables with only two columns.
- the first column can contain a value used like index, or a reference to a name or any other object, however the name or the value is single in this column for all the lines of the table;
- and the second, an unspecified value associated with this name or this value.
- with this property, a dictionary thus functions like a table with a column, but whose index can be of value or unspecified type, and is not restricted with a simple interval of entireties.
Among the operators preset, most important is def, it allows to add an association name-value in the dictionary running, which makes it possible to define new variables with their value, or to modify their value, and to define or redefine functions. One thus notes, that in Postscript, the achievable code is a data, almost like the others, and can be created with the flight, modified.
Examples:
-
/pi 3.14157 def: the variable of name pi defines, with the numerical value 3,14157; -
/comptor meter 1 add def: 1 to the named variable meter adds. -
/incremente {1 add} def: the function defines increments, which adds 1 to the parameter -
/comptor meter increments def: seek the value associated with the named variable " compteur" in the current dictionary and this name by its value replaces, then this value is incremented thanks to the function defined in the top, and the result is stored (by the function " def") in the variable named by " /compteur" in the current dictionary. In other words the named variable " compteur" in the range of dictionaries (by beginning research with the current dictionary) will be incremented.
In the last example above, nothing indicates that the named variable " compteur" will be the same one as that from which one extracted the value. Indeed " def" is used to store an association name-value only in the current dictionary, and any of the other dictionaries in the pile of range. Out, the reading of the variable meter (the second reference in the code above) can turn over the value of a variable found in another dictionary that the current dictionary (or to produce an exception to the execution if none the dictionaries in the pile of range contains a variable of this name): in this case, a new variable will be added by " def" in the current dictionary, without modifying the variable of origin where it was found and which will thus preserve its value; however as long as the dictionary running will be active, the new variable will mask the old one. This device thus makes it possible to differently manage local variables than by a relative position in the pile.
PostScript can differentiate the references to a variable (by its name indicated after a " /") and those with its value. However the reference is solved in no dictionary of range as long as one did not associate it with a dictionary to seek it. When a name is used without " /" initial, it is immediately required at the time of compilation of function in dictionaries of range active (while starting with the current dictionary during compilation and not that which will be active with the execution of the function), then the name of the variable is replaced with the execution in the pile by the value associated with this name in the dictionary where the name was found.
Also, to create a complete reference to a well defined variable and not its of the same value or another variable name in another dictionary, one must indicate not only the name of this variable, but also a reference to the dictionary which contains it and where it must be required. If one reference not the dictionary (for example while not prefixing by a /), the resolution of the name is dynamic and can thus refer the varaibles different ones according to the context from execution.
Postcript thus defines two contexts distinct from use of a reference to a variable:
- in the context of compilation of a definition of function, the reference found in the dictionary running (with moement of compilation) is solved immediately, but the value is not immediately déréférencée; instead of that, the reference is piled up and will be stored then in the code to the moment when the function will be indeed defined.
- then when the code of the function is carried out, any reference of piled up variable is carried out by replacing it in by the value of the variable independently of the current dictionary.
def which is done always according to the dictionary running to only moement of the execution.
Operators
Examples
Implementation
PostScript is under license of the Adobe company. Nevertheless there exists a free PostScript interpreter, Ghostscript.
Internal bonds
- Ghostscript
- TeX
- Latex
External bonds
- http://www.adobe.com/products/postscript/resources.html
- http://www.quite.com/ps/
See too
- PCL
- Forth : computer programming language based on the same principles (pile, dictionary, Polish notation reverse…)
Beats-smg: PostScript
| Random links: | EMF | Devil May Cry 3 | Lucien Canary | Emile the African | Kotka Peli-Karhut |