Immediately evaluated names, Immediately evaluated names 2 – Apple LaserWriter Select 310 Printer User Manual

Page 53

Advertising
background image

C H A P T E R 2

LaserWriter Select 310 Software

PostScript Language Changes

41

The second way to create a packed array is to build it explicitly by invoking the
packedarray

operator with a list of operands to be incorporated into a new

packed array.

Immediately Evaluated Names

2

The PostScript language syntax has been extended to include a new kind of name token,
the immediately evaluated name. When the scanner encounters the token //name,
(a name preceded by two slashes with no intervening spaces), it immediately looks up
the name in the context of the current dictionary stack and substitutes the corresponding
value for the name. If the name is not found, an undefined error occurs.

The substitution occurs immediately, regardless of whether or not the token appears
inside an executable array delimited by {...}.

Note

This process is a substitution and not an execution. This means the
name’s value is not executed but is substituted for the name itself, just
as if the load operator had been applied to the name.

This substitution is related to the action performed by the bind operator. See the
PostScript Language Reference Manual for further information. However, while bind
substitutes only for those names with values that are operators, each occurrence of
the //name syntax is replaced by the value associated with name, regardless of the
value’s type. The following examples illustrate this.

/a 3 def

/b {(test) print} def

//a =>3

//b => {(test) print}

{//a//b a /b}=> {3 {(test) print} a /b

Using immediately evaluated names serves a similar purpose to using the bind
operator. That is, it causes names in procedures to be tightly bound to their values.

W AR N I N G

Indiscriminate use of immediately evaluated
names may change the semantics of a program.

Specifically, when the interpreter encounters a procedure object directly, it simply pushes
it onto the operand stack. When it encounters an object indirectly, by looking up an
executable name, it executes the procedure. Therefore, execution of the program
fragments {...b...} and {...//b...} may have different effects if the name of b is a
procedure. See Section 3.6 of the PostScript Language Reference Manual, second edition, for
further information.

The immediately evaluated name facility is present in all versions of the PostScript
interpreter since version 25.0. Earlier versions of the interpreter will scan //name as two
distinct tokens: / as a literal name with no text at all, and /name as a literal name with
the text name.

Advertising