Systemdict, globaldict, userdict, Dictionary stack – AMT Datasouth PAL User Manual
Page 12

6
PAL Language Reference
second "add" and the "3" from the first add and multiplies them together. It then pushes the result,
"27," onto the operand stack.
The following diagram shows the contents of the operand stack when PAL finishes processing
each object in the above sequence.
1
2
add
4
5
add
mul
Stack
5
2
4
4
9
1
1
3
3
3
3
29
2.7.
systemdict, globaldict, userdict
PAL supports a data structure called a dictionary. Dictionaries contain an arbitrary collection of
objects organized into pairs. PAL treats the first object of each pair as the key object, and the
second object as the value object. This organization allows PAL to search a dictionary for a
particular key object, and recover the value object associated with the key.
When the PAL interpreter initializes, it automatically creates three dictionaries to help it keep track
of the various objects a PAL programmer will store into the printer's memory. PAL gives these
dictionaries the names systemdict, globaldict, and userdict.
Initially, userdict and globaldict do not contain any objects. systemdict contains all the names
which PAL recognizes as operators, as well as other predefined names like true, false, and mark.
The operator names themselves do not actually instruct the PAL interpreter to perform an op-
eration. Instead, PAL has a special internal object type known as an intrinsic operator object.
When the PAL interpreter encounters one of these intrinsic operator objects, the interpreter
performs the action indicated by the object.
systemdict contains all the operator names as key objects. It also contains all the intrinsic operator
objects as value objects associated with the appropriate name objects. Therefore, when PAL
receives an executable name object from the host computer, PAL searches systemdict to find a
dictionary key entry which matches the name object.
When PAL locates the matching name, the interpreter then recovers the value object associated
with the name. For the operator names, PAL will find an intrinsic operator object associated with
the name. The PAL interpreter then performs the action indicated by the intrinsic operator object.
2.8.
Dictionary Stack
During initialization, PAL pushes the three standard dictionaries, systemdict, globaldict, and
userdict onto an internal structure known as the dictionary stack. Therefore, immediately after
initialization, the dictionary stack contains the following.
Dictionary Stack
userdict
globaldict
systemdict