1. end
Pops the current dictionary from the dictionary stack.
1.2. Stack Effects
| Level | Object |
|---|---|
(none) |
Dictionary stack has at least 3 dictionaries |
| Level | Object |
|---|---|
(none) |
Dictionary stack decreased by one |
1.3. Description
end pops the current dictionary off the dictionary stack, making the dictionary below it the new current dictionary.
If end attempts to pop the bottommost instance of userdict, it executes [dictstackunderflow] error. The permanent dictionaries (systemdict, globaldict, userdict) cannot be removed.
1.5. Examples
10 dict begin
/x 100 def
end
% x no longer accessible
dict1 begin
/var1 1 def
dict2 begin
/var2 2 def
end
% var2 no longer accessible
% var1 still accessible
end
% var1 no longer accessible
{
mydict begin
% ... operations that might fail ...
end
} stopped {
end % Clean up dict stack on error
} if
1.6. Common Use Cases
1.7. Common Pitfalls
end % Error: no matching begin
Cannot Pop Permanent Dictionaries - Cannot pop systemdict or the bottommost userdict.
|
% After many ends...
end % Eventually: dictstackunderflow
| Use Defensive Coding - In error handlers, ensure dictionary stack is properly balanced. |
1.8. Error Conditions
| Error | Condition |
|---|---|
[ |
Attempt to pop bottommost userdict, or stack already at minimum |
1.9. Implementation Notes
-
Dictionary stack minimum: systemdict, userdict (Level 1)
-
Dictionary stack minimum: systemdict, globaldict, userdict (Level 2)
-
Very fast operation
-
Does not modify operand stack
1.10. Best Practices
dict begin
% ... operations ...
end % Always match
/myProc {
10 dict begin
% Local scope
end
} def
1.11. See Also
-
begin- Push dictionary onto stack -
currentdict- Get current dictionary -
countdictstack- Count stack depth -
dictstack- Examine dictionary stack