PostScript == 运算符

PostScript == operator

The value of == is not an operator, but rather a built-in procedure.

PLRM 第 526 页(pdf 第 540 页)。

内置程序,是否表示这是一个PostScript程序:

{ something here }

或实际功能,例如在 Java 你必须定义自己?

这是一个程序。

我不会说 Java,但在 PostScript 中,如果它是可执行文件,并且它不是运算符(语言的一部分),那么您必须自己定义它。

请注意,在 PostScript 中也可以重新定义运算符,因此仅仅因为它具有运算符的名称,并不意味着它 运算符,它可能仍然是一个程序。

您可以使用 /== load == 查看 ghostscript 的实现。

或者获取 Frank Meritt Braswell 的书 Inside Postscript。它有一整章介绍 == 过程如何在 Adob​​e 的打印机实现中工作。

但是简单的框架是基于 type 运算符的属性,它产生一个类型名。更具体地说,它产生一个 可执行名称 来指定参数的类型。所以你可以很容易地用字典实现类型转换。

<<
    /integertype { } % handle integer case
    /realtype { }    % handle floating-point case
    /arraytype { }   % handle array case
>> begin
5 type exec
2.0 type exec
{a b c} type exec

不同类型的对象会导致执行不同的过程。

使用它,我们可以处理可能传递给过程的不同类型。

/my== {
     <<
     /integertype { =string cvs print }
     /realtype { =string cvs print }
     /arraytype { dup xcheck {
                      ({ ) print {my==} forall (} ) print
                  }{
                      ([ ) print {my==} forall (] ) print
                  } }
     >> begin dup type exec
} def

=string(书中有描述)是一个预分配的 128 字节暂存缓冲区,由 === 过程用于此确切目的:提供参数给cvs.