1. load

Searches dictionary stack for a key and returns its associated value.

1.1. Syntax

key load → value

1.2. Stack Effects

Table 1. Before
Level Object

0

key (name or other object)

Table 2. After
Level Object

0

value (associated with key)

1.3. Description

load searches for key in each dictionary on the dictionary stack, starting with the topmost (current) dictionary.

  • If found: pushes the associated value

  • If not found: executes [undefined] error

load looks up keys the same way the interpreter looks up executable names, but always pushes the value (never executes it).

1.4. PostScript Level

Level 1 and later

1.5. Examples

Loading values
/pi 3.14159 def
/pi load  % Returns 3.14159
Loading procedures
/avg { add 2 div } def
/avg load  % Returns { add 2 div }, doesn't execute
Difference from execution
/add load  % Pushes add operator
add        % Executes add operator

1.6. Common Use Cases

1.6.1. Getting Procedure Objects

/myProc { complex code } def
/myProc load
% Can now manipulate procedure as data

1.6.2. Conditional Loading

/setting where {
  /setting load
} {
  defaultValue
} ifelse

1.6.3. Dynamic Lookup

(variableName) cvn load  % Load dynamically named variable

1.7. Common Pitfalls

Always Pushes Value - load never executes values, even executable ones.
/proc { 1 2 add } def
proc       % Executes, pushes 3
/proc load % Pushes { 1 2 add }
Undefined Keys - If key not found, [undefined] error occurs.
/nonexistent load  % Error: undefined
Use where First - Check if key exists before loading:
/key where {
  /key load
} {
  % Handle missing key
} ifelse

1.8. Error Conditions

Error Condition

[invalidaccess]

Dictionary on stack has no-access attribute

[stackunderflow]

No operand on stack

[typecheck]

Operand wrong type

[undefined]

Key not found in any dictionary on stack

1.9. Implementation Notes

  • Searches dictionary stack top-down

  • Same lookup mechanism as interpreter uses

  • Fast operation (hash table lookup)

  • Does not create new objects (returns actual value)

1.10. Comparison with get

Operation load get

Search scope

Entire dictionary stack

Specific dictionary only

Not found

[undefined] error

[undefined] error

Syntax

key load

dict key get

1.11. See Also

  • store - Store value in dictionary stack

  • def - Define in current dictionary

  • where - Find which dictionary contains key

  • get - Get from specific dictionary

  • known - Check if key exists


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.