]> gitweb.factorcode.org Git - factor.git/commitdiff
prettyprint: change how we trap pprint errors.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 3 Jan 2022 04:39:20 +0000 (20:39 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 3 Jan 2022 04:39:40 +0000 (20:39 -0800)
basis/prettyprint/prettyprint.factor
basis/prettyprint/sections/sections.factor

index 746b98e2e832a635703e91e1a2a40d2640d986b2..5e87cb859c23be4748c8bd22d92913942c1bfe1f 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2003, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays classes colors combinators
-continuations generic grouping io io.streams.string io.styles
-kernel make math math.parser namespaces prettyprint.config
-prettyprint.custom prettyprint.sections sequences strings
-vocabs.prettyprint words ;
+USING: accessors arrays colors combinators grouping io
+io.streams.string io.styles kernel make math namespaces
+prettyprint.config prettyprint.custom prettyprint.sections
+sequences strings vocabs.prettyprint words ;
 IN: prettyprint
 
 : with-use ( obj quot -- )
@@ -35,19 +34,11 @@ IN: prettyprint
 
 : short. ( obj -- ) pprint-short nl ;
 
-: error-in-pprint ( obj -- str )
-    class-of name>> "~pprint error: " "~" surround ;
-
 : .b ( n -- ) 2 number-base [ . ] with-variable ;
 : .o ( n -- ) 8 number-base [ . ] with-variable ;
 : .h ( n -- ) 16 number-base [ . ] with-variable ;
 
-: stack. ( seq -- )
-    [
-        [ short. ] [
-            drop [ error-in-pprint ] keep write-object nl
-        ] recover
-    ] each ;
+: stack. ( seq -- ) [ short. ] each ;
 
 : .s ( -- ) get-datastack stack. ;
 : .r ( -- ) get-retainstack stack. ;
index dd8205dcdf03b45270845704daedd17b400eee0f..2dac1baa368e073c98a217eb44e01ee5a72de72a 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2003, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors classes.maybe combinators
+USING: accessors classes classes.maybe combinators
 combinators.short-circuit continuations hashtables io io.styles
 kernel make math namespaces prettyprint.config sequences sets
 splitting strings vocabs vocabs.parser words ;
@@ -368,5 +368,9 @@ M: block long-section
         [ pprinter-manifest ] [ f ] if
     ] with-scope ; inline
 
+: error-in-pprint ( obj -- )
+    <flow class-of name>> "~pprint error: " "~" surround text block> ;
+
 : with-pprint ( obj quot -- )
+    '[ _ [ drop error-in-pprint ] recover ]
     f make-pprint drop do-pprint ; inline