The value of == is not an operator, but rather a built-in procedure.
PLRM page 526 (pdf page 540).
a built-in procedure, does this mean that this is a PostScript procedure:
{ something here }
or an actual function e.g. in Java that you have to define yourself?
You can peek at ghostscript's implementation with /== load ==
.
Or get the book Inside Postscript by Frank Meritt Braswell. It has an entire chapter about how the ==
procedure works in Adobe's printer implementations.
But the simple framework is based around the properties of the type
operator which yields a typename. More specifically, it yields an executable name which designates the type of the argument. So you can easily implement a type-switch with a dictionary.
<<
/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
The different typed objects cause different procedures to be executed.
Using this, we can handle the different types that might be passed to the procedure.
/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
(described in the book) is a pre-allocated 128-byte scratch buffer used by the =
and ==
procedures for this exact purpose: supplying the argument to cvs
.