X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=scheme-primitives.4th;h=fdb28d37e1eb911251a0dd60f80e73bfe7b8f787;hb=e0ca5b6fd7381323cb9737f0ca6bfec9ede3eb7d;hp=e5a7dba89f4189877e6ce6dfb21f79e40286f236;hpb=61f902750c854d52bc37a5903e07b7e84f7081c4;p=scheme.forth.jl.git diff --git a/scheme-primitives.4th b/scheme-primitives.4th index e5a7dba..fdb28d3 100644 --- a/scheme-primitives.4th +++ b/scheme-primitives.4th @@ -358,7 +358,7 @@ defer display :noname ( args -- none ) 2dup 1 ensure-arg-count - car print cr + car print none ; make-primitive write @@ -367,19 +367,31 @@ defer display 2dup car display cdr - nil-type istype? if 2drop exit then + nil? if 2drop exit then pair-type istype? if space recurse exit then ." . " display ; : displaychar ( charobj -- ) - drop emit + drop emit ; + +: (displaystring) ( charlist -- ) + nil? if + 2drop + else + 2dup car displaychar + cdr recurse + then +; + +: displaystring ( stringobj -- ) + drop pair-type (displaystring) ; :noname ( obj -- ) pair-type istype? if ." (" displaypair ." )" exit then character-type istype? if displaychar exit then - string-type istype? if (printstring) exit then + string-type istype? if displaystring exit then print ; is display @@ -388,7 +400,7 @@ defer display 2dup 1 ensure-arg-count car string-type ensure-arg-type - (printstring) cr + displaystring none ; make-primitive display-string @@ -397,7 +409,7 @@ defer display 2dup 1 ensure-arg-count car character-type ensure-arg-type - displaychar cr + displaychar none ; make-primitive display-character @@ -406,7 +418,7 @@ defer display 2dup 1 ensure-arg-count car - display cr + display none ; make-primitive display @@ -428,3 +440,19 @@ defer display apply ; make-primitive apply + +( ==== Error System ==== ) + +:noname ( args -- result ) + bold fg red + + nil? if + ." Error." + else + ." Error: " car display + then + + reset-term + + recoverable-exception throw +; make-primitive error