Next: 2.11.9 systemdict Up: 2.11 Dictionary reference Previous: 2.11.7 outputsdict Contents Index

##
2.11.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 idup type $sprintsdict load exch get eval
    } def

Table 2.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.
class depth classtype string | Create syntactical string from class.
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.
handle depth handletype string | Create syntactical string from handle.
instance depth instancetype string | Create syntactical string from instance.
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.
regex depth regextype string | Create syntactical string from regex.
regsub depth regsubtype string | Create syntactical string from regsub.
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.
  Error(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.
  Error(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>

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

        onyx:0> sprintsdict begin
        onyx:0> vclass
        onyx:1> dup 0 classtype print `\n' print flush
        -class-
        onyx:1> dup 1 classtype print `\n' print flush
        -class-
        onyx:1>

condition depth conditiontype string:
  Input(s):
    condition:
      A condition object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of condition.
  Error(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.
  Error(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.
  Error(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.
  Error(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>

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

        onyx:0> sprintsdict begin
        onyx:0> taggedhandle
        onyx:1> dup 0 handletype print `\n' print flush
        =tagged=
        onyx:1> 1 handletype print `\n' print flush
        =tagged=
        onyx:0> untaggedhandle
        onyx:1> dup 0 handletype print `\n' print flush
        -handle-
        onyx:1> 1 handletype print `\n' print flush
        -handle-
        onyx:0>

instance depth instancetype string:
  Input(s):
    instance:
      An instance object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of instance.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a syntactical string representation of instance.
  Example(s):

        onyx:0> sprintsdict begin
        onyx:0> vinstance
        onyx:1> dup 0 instancetype print `\n' print flush
        -instance-
        onyx:1> dup 1 instancetype print `\n' print flush
        -instance-
        onyx:1>

integer depth integertype string:
  Input(s):
    integer:
      An integer object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of integer.
  Error(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.
  Error(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.
  Error(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.
  Error(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.
  Error(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.
  Error(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.
  Error(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-)
        cstack: ()
        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>

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

        onyx:0> sprintsdict begin
        onyx:0> `' regex
        onyx:1> dup 0 regextype print `\n' print flush
        -regex-
        onyx:1> dup 1 regextype print `\n' print flush
        -regex-
        onyx:1>

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

        onyx:0> sprintsdict begin
        onyx:0> `' `' regsub
        onyx:1> dup 0 regsubtype print `\n' print flush
        -regsub-
        onyx:1> dup 1 regsubtype print `\n' print flush
        -regsub-
        onyx:1>

real depth realtype string:
  Input(s):
    real:
      A real object.
    depth:
      Recursion depth.
  Output(s):
    string:
      Syntactical string representation of real.
  Error(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.
  Error(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.
  Error(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.
  Error(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: 2.11.9 systemdict Up: 2.11 Dictionary reference Previous: 2.11.7 outputsdict Contents Index