Next: 2.11.8 sprintsdict Up: 2.11 Dictionary reference Previous: 2.11.6 onyxdict Contents Index

##
2.11.7 outputsdict

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

There is an entry in outputsdict for each Onyx type. Each entry renders objects that correspond to its name using optional flags stored in a dictionary. The following flags are supported for all types:

`$n`:
  Maximum length, in bytes. Default: disabled.
`$w`:
  Minimum length, in bytes. Default: disabled.
`$j`:
  Justification. Legal values:
  `$l`:
    Left.
  `$c`:
    Center.
  `$r`:
    Right (default).
`$p`:
  Padding character. Default: `` '`.
`$r`:
  Syntactic rendering recursion depth. Default: 1.

The following additional flags are supported for integers:

`$b`:
  Base, from 2 to 36. Default: 10.
`$s`:
  Sign. Legal values:
  `$-`:
    Only print sign if output is negative (default).
  `$+`:
    Always print sign.

The following additional flags are supported for reals:

`$d`:
  Digits of precision past decimal point. Default: 6.
`$e`:
  Exponential notation, if true. Default: false.

Table 2.8: outputsdict summary
Input(s) Op/Proc/Var Output(s) | Description
array flags arraytype string | Create formatted string from array.
boolean flags booleantype string | Create formatted string from boolean.
class flags classtype string | Create formatted string from class.
condition flags conditiontype string | Create formatted string from condition.
dict flags dicttype string | Create formatted string from dict.
file flags filetype string | Create formatted string from file.
fino flags finotype string | Create formatted string from fino.
handle flags handletype string | Create formatted string from handle.
instance flags instancetype string | Create formatted string from instance.
integer flags integertype string | Create formatted string from integer.
mark flags marktype string | Create formatted string from mark.
mutex flags mutextype string | Create formatted string from mutex.
name flags nametype string | Create formatted string from name.
null flags nulltype string | Create formatted string from null.
operator flags operatortype string | Create formatted string from operator.
pmark flags pmarktype string | Create formatted string from pmark.
real flags realtype string | Create formatted string from real.
regex flags regextype string | Create formatted string from regex.
regsub flags regsubtype string | Create formatted string from regsub.
stack flags stacktype string | Create formatted string from stack.
string flags stringtype string | Create formatted string from string.
thread flags threadtype string | Create formatted string from thread.

array flags arraytype string:
  Input(s):
    array:
      An array object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of array.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of array.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> [1 [2 3] 4]
        onyx:1> dup <$w 9 $p `_' $r 0> arraytype print `\n' print flush
        __-array-
        onyx:1> dup <$w 9 $p `_' $r 1> arraytype print `\n' print flush
        [1 -array- 4]
        onyx:1>

boolean flags booleantype string:
  Input(s):
    boolean:
      A boolean object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of boolean.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of boolean.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> false
        onyx:1> dup <$n 3> booleantype print `\n' print flush
        fal
        onyx:1> dup <$n 7> booleantype print `\n' print flush
        false
        onyx:1>

class flags classtype string:
  Input(s):
    class:
      A class object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of class.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of class.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> vclass
        onyx:1> <$w 30 $p `.' $j $c> classtype print `\n' print flush
        ...........-class-............
        onyx:0>

condition flags conditiontype string:
  Input(s):
    condition:
      A condition object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of condition.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of condition.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> condition
        onyx:1> <$w 15 $p `_' $j $c> booleantype print `\n' print flush
        __-condition-__
        onyx:0>

dict flags dicttype string:
  Input(s):
    dict:
      A dict object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of dict.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of dict.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> <$foo `foo'> <$w 30 $p `.' $j $r> dicttype print `\n' print flush
        ..................<$foo `foo'>
        onyx:0>

file flags filetype string:
  Input(s):
    file:
      A file object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of file.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of file.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> stdin
        onyx:1> <$w 30 $p `.' $j $c> filetype print `\n' print flush
        ............-file-............
        onyx:0>

fino flags finotype string:
  Input(s):
    fino:
      A fino object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of fino.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of fino.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> (
        onyx:1> <$w 30 $p `.' $j $c> finotype print `\n' print flush
        ............-fino-............
        onyx:0>

handle flags handletype string:
  Input(s):
    handle:
      A handle object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of handle.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted 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''.

        onyx:0> outputsdict begin
        onyx:0> taggedhandle
        onyx:1> <$w 30 $p `.' $j $l handletype print `\n' print flush
        =tagged=......................
        onyx:0>

instance flags instancetype string:
  Input(s):
    instance:
      An instance object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of instance.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of instance.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> vinstance
        onyx:1> <$w 30 $p `.' $j $c> instancetype print `\n' print flush
        ..........-instance-..........
        onyx:0>

integer flags integertype string:
  Input(s):
    integer:
      An integer object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of integer.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of integer.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> 42 <$w 6 $p `_' $j $c $s $-> integertype print `\n' print flush
        __42__
        onyx:0> 42 <$w 6 $p `_' $j $c $s $+> integertype print `\n' print flush
        _+42__
        onyx:0> `0x' print 42 <$w 6 $p `0' $b 16> integertype print `\n' print flush
        0x00002a
        onyx:0>

mark flags marktype string:
  Input(s):
    mark:
      A mark object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of mark.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of mark.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> mark
        onyx:1> <$w 30 $p `.' $j $c> marktype print `\n' print flush
        ............-mark-............
        onyx:0>

mutex flags mutextype string:
  Input(s):
    mutex:
      A mutex object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of mutex.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of mutex.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> mutex
        onyx:1> <$w 30 $p `.' $j $c> mutextype print `\n' print flush
        ...........-mutex-............
        onyx:0>

name flags nametype string:
  Input(s):
    name:
      A name object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of name.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of name.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> $foo
        onyx:1> <$w 30 $p `.' $j $c> nametype print `\n' print flush
        .............$foo.............
        onyx:0>

null flags nulltype string:
  Input(s):
    null:
      A null object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of null.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of null.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> null
        onyx:1> <$w 30 $p `.' $j $c> nulltype print `\n' print flush
        .............null.............
        onyx:0>

operator flags operatortype string:
  Input(s):
    operator:
      An operator object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of operator.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted 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> outputsdict begin
        onyx:0> ~realtime
        onyx:1> <$w 30 $p `.' $j $c> operatortype print `\n' print flush
        .........--realtime--.........
        onyx:0>

pmark flags pmarktype string:
  Input(s):
    pmark:
      A pmark object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of pmark.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of pmark.
  Example(s):

        onyx:0> outputsdict 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> <$w 30 $p `.' $j $c> pmarktype print `\n' print flush
        ...........-pmark-............
        onyx:0>

real flags realtype string:
  Input(s):
    real:
      A real object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of real.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of real.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> 6.022e23 <$d 4> realtype print `\n' print flush
        602200000000000027262976.0000
        onyx:0> 6.022e23 <$d 4 $e true> realtype print `\n' print flush
        6.0220e+23
        onyx:0> 6.022e23 <$d 0 $e true> realtype print `\n' print flush
        6e+23
        onyx:0> 6.022e23 <$d 4 $w 40 $p `0'> realtype print `\n' print flush
        00000000000602200000000000027262976.0000
        onyx:0>

regex flags regextype string:
  Input(s):
    regex:
      A regex object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of regex.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of regex.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> `' regex
        onyx:1> <$w 30 $p `.' $j $c> regextype print `\n' print flush
        ...........-regex-............
        onyx:0>

regsub flags regsubtype string:
  Input(s):
    regsub:
      A regsub object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of regsub.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of regsub.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> `' `' regsub
        onyx:1> <$w 30 $p `.' $j $c> regsubtype print `\n' print flush
        ...........-regsub-...........
        onyx:0>

stack flags stacktype string:
  Input(s):
    stack:
      A stack object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of stack.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of stack.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> (1 (2 3) 4)
        onyx:1> dup <$w 9 $p `_' $r 0> stacktype print `\n' print flush
        __-stack-
        onyx:1> <$w 9 $p `_' $r 1> stacktype print `\n' print flush
        (1 -stack- 4)
        onyx:0>

string flags stringtype string:
  Input(s):
    string:
      A string object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of string.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of string.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> `A string'
        onyx:1> <$w 30 $p `.' $j $c> stringtype print `\n' print flush
        ...........A string...........
        onyx:0>

thread flags threadtype string:
  Input(s):
    thread:
      A thread object.
    flags:
      Formatting flags.
  Output(s):
    string:
      Formatted string representation of thread.
  Error(s):
    stackunderflow.
    typecheck.
  Description:
    Create a formatted string representation of thread.
  Example(s):

        onyx:0> outputsdict begin
        onyx:0> () {} thread
        onyx:1> <$w 30 $p `.' $j $c> threadtype print `\n' print flush
        ...........-thread-...........
        onyx:0>

Next: 2.11.8 sprintsdict Up: 2.11 Dictionary reference Previous: 2.11.6 onyxdict Contents Index