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
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. |
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>
onyx:0> sprintsdict begin onyx:0> true onyx:1> dup 0 booleantype print `\n' print flush true onyx:1>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>