1. xcheck

Tests whether an object has the executable attribute.

1.1. Syntax

any xcheck → bool

1.2. Stack Effects

Table 1. Before
Level Object

0

any (any object)

Table 2. After
Level Object

0

bool (true if executable, false if literal)

1.3. Description

xcheck tests whether the operand has the executable or literal attribute:

  • Returns true if the object is executable

  • Returns false if the object is literal

This tests the executable/literal attribute only, not the access attribute (e.g., execute-only, readonly).

1.4. PostScript Level

Level 1 and later

1.5. Examples

Checking names
/abc xcheck      % false (literal name)
abc xcheck       % true (executable name) - if abc is defined
Checking procedures
{ 1 2 add } xcheck      % true (procedures are executable)
{ 1 2 add } cvlit xcheck  % false (converted to literal)
Checking numbers and strings
123 xcheck       % false (numbers always literal)
(text) xcheck    % false (strings always literal)

1.6. Common Use Cases

1.6.1. Validating Procedure Arguments

/execute-if-proc {
  dup xcheck {
    exec
  } {
    % Not executable, handle differently
  } ifelse
} def

1.6.2. Type-Safe Operations

/safe-exec {
  dup xcheck not {
    /typecheck cvx exec
  } if
  exec
} def

1.6.3. Debugging

/show-attr {
  dup xcheck
  { (executable) }
  { (literal) }
  ifelse print
} def

1.7. Common Pitfalls

Tests Attribute, Not Access - xcheck does not test access permissions like execute-only.
% xcheck returns true even for execute-only objects
proc executeonly xcheck  % true
Most Objects Are Literal - Numbers, strings, and array literals are all literal by default.
Combine with type - Use type to check object type along with executability.

1.8. Error Conditions

Error Condition

[stackunderflow]

No operand on stack

1.9. Implementation Notes

  • Very fast operation (checks single bit in object header)

  • Does not modify the object

  • Works on any object type

  • Complementary test to attribute queries

1.10. Executable vs. Literal Summary

Object Type Default Attribute Can Change?

Integer

Literal

No

Real

Literal

No

Boolean

Literal

No

String

Literal

Yes

Name

Depends on / prefix

Yes

Array

Literal ([ ])

Yes

Procedure

Executable ({ })

Yes

Mark

Literal

No

Null

Literal

No

Operator

Executable

No

1.11. See Also

  • cvlit - Convert to literal attribute

  • cvx - Convert to executable attribute

  • rcheck - Test if readable

  • wcheck - Test if writable

  • type - Get object type


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.