1 ! Copyright (C) 2003, 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: alien arrays generic hashtables io kernel math
5 namespaces parser sequences strings styles vectors words
6 prettyprint-internals ;
8 : with-pprint ( quot -- )
10 V{ } clone recursion-check set
11 H{ } <flow> f ?push pprinter-stack set
12 call end-blocks do-pprint
15 : pprint ( obj -- ) [ pprint* ] with-pprint ;
21 } clone [ pprint ] bind terpri ;
23 : unparse ( obj -- str ) [ pprint ] string-out ;
25 : pprint-short ( obj -- )
31 } clone [ pprint ] bind ;
33 : short. ( obj -- ) pprint-short terpri ;
35 : unparse-short ( obj -- str ) [ pprint-short ] string-out ;
37 : .b ( n -- ) >bin print ;
38 : .o ( n -- ) >oct print ;
39 : .h ( n -- ) >hex print ;
41 GENERIC: summary ( object -- string )
44 "an instance of the " swap class word-name " class" 3append ;
47 "Input: " swap input-string dup string?
48 [ "\n" split1 "..." "" ? append ] [ unparse-short ] if