09.12.2012 Views

Preface - Adobe

Preface - Adobe

Preface - Adobe

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3<br />

Literal and Executable<br />

36<br />

Language<br />

Every object is either literal or executable. This distinction comes into play when<br />

the interpreter attempts to execute the object.<br />

• If the object is literal, the interpreter treats it strictly as data and pushes it on<br />

the operand stack for use as an operand of some subsequent operator.<br />

• If the object is executable, the interpreter executes it.<br />

What it means to execute an object depends on the object’s type; this is described<br />

in Section 3.5, “Execution.” For some object types, such as integers, execution<br />

consists of pushing the object on the operand stack; the distinction between literal<br />

and executable integers is meaningless. But for other types, such as names,<br />

operators, and arrays, execution consists of performing a different action.<br />

• Executing an executable name causes it to be looked up in the current dictionary<br />

context and the associated value to be executed.<br />

• Executing an executable operator causes some built-in action to be performed.<br />

• Executing an executable array (otherwise known as a procedure) causes the elements<br />

of the array to be executed in turn.<br />

As described in Section 3.2, “Syntax,” some tokens produce literal objects and<br />

some produce executable ones.<br />

• Integer, real, and string constants are always literal objects.<br />

• Names are literal if they are preceded by / and executable if they are not.<br />

• The [ and ] operators, when executed, produce a literal array object with the enclosed<br />

objects as elements. Likewise, > (LanguageLevel 2) produce a<br />

literal dictionary object.<br />

• { and } enclose an executable array or procedure.<br />

Note: As mentioned above, it does not matter whether an object is literal or executable<br />

when it is accessed as data, only when it is executed. However, referring to an<br />

executable object by name often causes that object to be executed automatically; see<br />

Section 3.5.5, “Execution of Specific Types.” To avoid unintended behavior, it is best<br />

to use the executable attribute only for objects that are meant to be executed, such as<br />

procedures.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!