Next: 1.8.9 systemdict Up: 1.8 Dictionary reference Previous: 1.8.7 outputsdict Contents Index

##
1.8.8 sprintsdict

The sprintsdict dictionary is primarily used to support sprints , but its contents may be of use to an application that wishes to extend or modify syntactical printing.

There is an entry in sprintsdict for each Onyx type. If there is a syntactically valid representation for an object and the recursion depth is greater than 0, the corresponding operator creates a string that syntactically represents the object. Otherwise, a string with a non-syntictical representation of the object is created, except for booleans, integers, names, nulls, reals, and strings, for which the results are always syntactical. If the recursion depth is greater than 0, the operators will recursively convert any contained objects.

The implementation of sprints is useful in illustrating a useful method of doing type-dependent operations:

    /sprints {
            1 index type /sprintsdict load exch get eval
    } def

Table 1.9: sprintsdict summary
Input(s) | Op/Proc/Var | Output(s) | Description
array depth | arraytype | string | Create syntactical string from array.
boolean depth | booleantype | string | Create syntactical string from boolean.
condition depth | conditiontype | string | Create syntactical string from condition.
dict depth | dicttype | string | Create syntactical string from dict.
file depth | filetype | string | Create syntactical string from file.
fino depth | finotype | string | Create syntactical string from fino.
hook depth | hooktype | string | Create syntactical string from hook.
integer depth | integertype | string | Create syntactical string from integer.
mark depth | marktype | string | Create syntactical string from mark.
mutex depth | mutextype | string | Create syntactical string from mutex.
name depth | nametype | string | Create syntactical string from name.
null depth | nulltype | string | Create syntactical string from null.
operator depth | operatortype | string | Create syntactical string from operator.
pmark depth | pmarktype | string | Create syntactical string from pmark.
real depth | realtype | string | Create syntactical string from real.
stack depth | stacktype | string | Create syntactical string from stack.
string depth | stringtype | string | Create syntactical string from string.
thread depth | threadtype | string | Create syntactical string from thread.

array depth arraytype string:
  Input(s):
    array:
      An array object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of array.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of array.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> [1 [2 3] 4]
        onyx:1> dup 0 arraytype print `\n' print flush
        -array-
        onyx:1> dup 1 arraytype print `\n' print flush
        [1 -array- 4]
        onyx:1> dup 2 arraytype print `\n' print flush
        [1 [2 3] 4]
        onyx:1>

boolean depth booleantype string:
  Input(s):
    boolean:
      A boolean object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of boolean.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of boolean.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> true
        onyx:1> dup 0 booleantype print `\n' print flush
        true
        onyx:1>

condition depth conditiontype string:
  Input(s):
    condition:
      A condition object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of condition.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of condition.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> condition
        onyx:1> dup 0 conditiontype print `\n' print flush
        -condition-
        onyx:1> dup 1 conditiontype print `\n' print flush
        -condition-
        onyx:1>

dict depth dicttype string:
  Input(s):
    dict:
      A dict object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of dict.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of dict.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> </a `a' /subdict </b `b'>>
        onyx:1> dup 0 dicttype print `\n' print flush
        -dict-
        onyx:1> dup 1 dicttype print `\n' print flush
        </subdict -dict- /a `a'>
        onyx:1> dup 2 dicttype print `\n' print flush
        </subdict </b `b'> /a `a'>
        onyx:1>

file depth filetype string:
  Input(s):
    file:
      A file object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of file.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of file.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> stdout
        onyx:1> dup 0 filetype print `\n' print flush
        -file-
        onyx:1> dup 1 filetype print `\n' print flush
        -file-
        onyx:1>

fino depth finotype string:
  Input(s):
    fino:
      A fino object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of fino.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of fino.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> (
        onyx:1> dup 0 finotype print `\n' print flush
        -fino-
        onyx:1> dup 1 finotype print `\n' print flush
        -fino-
        onyx:1>

hook depth hooktype string:
  Input(s):
    hook:
      A hook object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of hook.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of hook.
  Example(s):
    The following example is a bit contrived, since there is no way to create a hook object with a stock onyx interpreter. Therefore, imagine that an operator named taggedhook exists that creates a hook with a tag that is the name ``tagged'', and that an operator named untaggedhook exists that creates an untagged hook.

        onyx:0> sprintsdict begin
        onyx:0> taggedhook
        onyx:1> dup 0 hooktype print `\n' print flush
        =tagged=
        onyx:1> 1 hooktype print `\n' print flush
        =tagged=
        onyx:0> untaggedhook
        onyx:1> dup 0 hooktype print `\n' print flush
        -hook-
        onyx:1> 1 hooktype print `\n' print flush
        -hook-
        onyx:0>

integer depth integertype string:
  Input(s):
    integer:
      An integer object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of integer.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of integer.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> 42
        onyx:1> dup 0 integertype print `\n' print flush
        42
        onyx:1> dup 1 integertype print `\n' print flush
        42
        onyx:1>

mark depth marktype string:
  Input(s):
    mark:
      A mark object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of mark.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of mark.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> mark
        onyx:1> dup 0 marktype print `\n' print flush
        -mark-
        onyx:1> dup 1 marktype print `\n' print flush
        -mark-
        onyx:1>

mutex depth mutextype string:
  Input(s):
    mutex:
      A mutex object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of mutex.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of mutex.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> mutex
        onyx:1> dup 0 mutextype print `\n' print flush
        -mutex-
        onyx:1> dup 1 mutextype print `\n' print flush
        -mutex-
        onyx:1>

name depth nametype string:
  Input(s):
    name:
      A name object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of name.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of name.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> /foo
        onyx:1> dup 0 nametype print `\n' print flush
        /foo
        onyx:1> dup 1 nametype print `\n' print flush
        /foo
        onyx:1>

null depth nulltype string:
  Input(s):
    null:
      A null object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of null.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of null.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> null
        onyx:1> dup 0 nulltype print `\n' print flush
        -null-
        onyx:1> dup 1 nulltype print `\n' print flush
        -null-
        onyx:1>

operator depth operatortype string:
  Input(s):
    operator:
      An operator object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of operator.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of operator.
  Example(s):
    The following example shows an operator printed out with two leading and trailing dashes. If the interpreter cannot determine the name associated with an operator, as will be the case for custom operators, the operator will be printed as `-operator-`.

        onyx:0> sprintsdict begin
        onyx:0> //realtime
        onyx:1> dup 0 operatortype print `\n' print flush
        --realtime--
        onyx:1> 1 operatortype print `\n' print flush
        --realtime--
        onyx:0>

pmark depth pmarktype string:
  Input(s):
    pmark:
      A pmark object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of pmark.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of pmark.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> { //x
        Error /undefined
        ostack: (-pmark- /x)
        dstack: (-dict- -dict- -dict- -dict- -dict-)
        estack/istack trace (0..1):
        0:      -file-
        1:      --start--
        onyx:3> pop pop resume
        onyx:1> dup 0 pmarktype print `\n' print flush
        -pmark-
        onyx:1> dup 1 pmarktype print `\n' print flush
        -pmark-
        onyx:1>

real depth realtype string:
  Input(s):
    real:
      A real object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of real.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of real.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> 42.0
        onyx:1> dup 0 realtype print `\n' print flush
        4.200000e+01
        onyx:1> dup 1 realtype print `\n' print flush
        4.200000e+01
        onyx:1>

stack depth stacktype string:
  Input(s):
    stack:
      A stack object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of stack.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of stack.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> (1 (2 3) 4)
        onyx:1> dup 0 stacktype print `\n' print flush
        -stack-
        onyx:1> dup 1 stacktype print `\n' print flush
        (1 -stack- 4)
        onyx:1> dup 2 stacktype print `\n' print flush
        (1 (2 3) 4)
        onyx:1>

string depth stringtype string:
  Input(s):
    string:
      A string object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of string.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of string.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> `abcd'
        onyx:1> dup 0 stringtype print `\n' print flush
        `abcd'
        onyx:1> dup 1 stringtype print `\n' print flush
        `abcd'
        onyx:1>

thread depth threadtype string:
  Input(s):
    thread:
      A thread object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of thread.
  Errors(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of thread.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> thread
        onyx:1> dup 0 threadtype print `\n' print flush
        -thread-
        onyx:1> dup 1 threadtype print `\n' print flush
        -thread-
        onyx:1>

Next: 1.8.9 systemdict Up: 1.8 Dictionary reference Previous: 1.8.7 outputsdict Contents Index