A dictionary is a table whose elements are pairs of PostScript objects (number, string, name, operator, ...). We call the first element of a pair the 'key' and the second element the 'value'. The language includes operators inserting a key-value pair into a dictionary, operators looking up a key and fetching the associated value, and so on. For instance, put, get, load belong to these operators:
When the interpreter seeks to execute a name object, it first searches the current dictionary for the key. If the key isn't there, the interpreter searches the next lower dictionary on the dictionary stack. This continues until either it finds the key or it exhausts the dictionary stack. In the last case the interpreter issues an undefined error message.
Special dictionaries are systemdict, userdict, statusdict, and errordict. The systemdict dictionary is always the bottommost dictionary on the dictionary stack; it associates the names of all PostScript operators with their values (implementations).
When for instance you call the quit operator in systemdict the printer is restarted without the need of manually powering it off and on again.
%!File: Reset.ps systemdict begin quitThe begin operator pushes a dictionary onto the dictionary stack.
The statusdict dictionary is the repository for machine- and configuration-dependent operators and values in most implementations of the PostScript interpreter, for instance setdostartpage, setpapertray (Level 1).
PostScript experts characterize the understanding of the dictionary philosophy as 'the royal road to PostScript mastery'.
% userdict:
/showpage { } def % dummying
...
If no dictionary is specified
the interpreter puts the definitions into userdict.
% your own dictionary:
/mydict 11 dict def
mydict begin
/bd { bind def } bind def
...
end
mydict /Max get
In order to build your own font
you have to use a font dictionary:
% font dictionary:
/ExampleFont 12 dict def
ExampleFont begin
/FontType 3 def % your own font
...
CharacterDefs ... % definitions of types
/BuildChar
{ ... } def % mandatory
end
The error handling may also be redefined:
% errordict:
errordict begin
/handleerror
{ ... } def
end
In the real world, not only is error handling redefined
but also operators
such as copypage
and erasepage.
Ein Dictionary ist durch die neue Syntax "<< ... >>" oder durch die Operatoren begin--end gekennzeichnet. Die Konstruktion "<<...>>" ist praktisch die einzige Syntax, die exklusiv auf Level 2 unterstützt ist.