字典上的 PostScript forall

PostScript forall on dictionaries

根据 PLRM,在 dict 上执行 forall 的顺序无关紧要:

(p. 597) forall pushes a key and a value on the operand stack and executes proc for each key-value pair in the dictionary

...

(p. 597) The order in which forall enumerates the entries in the dictionary is arbitrary. New entries put in the dictionary during the execution of proc may or may not be included in the enumeration. Existing entries removed from the dictionary by proc will not be encountered later in the enumeration.

现在我正在执行一些代码:

/d 5 dict def
d /abc 123 put
d { } forall

我的输出(操作数栈)是:

--------top-
/abc
123
-----bottom-

ghostscript 和 PLRM(操作数栈)的输出是:

--------top-
123
/abc
-----bottom-
  1. 按什么顺序处理字典的键值对真的不重要吗?
  2. 在栈上,是先压值再压键,还是先压键? (因为 PLRM 只谈论 "a key and a value",但没有告诉你任何关于订单的信息)。

提前致谢

如果您在引用 PLRM 中的章节时引用页码可能会有所帮助,很难看出您是从哪里得到的。

执行forall时,forall枚举字典pairs的顺序是任意的,你没有影响。但是 forall 总是先按键再按值。即使这暗示在您(不完全)引用的文本中,您也可以从 forall 运算符中的示例中看出这是 hte 情况。

当您说 'my output' 时,您的意思是您正在编写自己的 PostScript 解释器吗?如果是这样,那么您的输出不正确,当按下 key/value 对时,首先按下键。