X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;ds=sidebyside;f=scheme-primitives.4th;h=86fbbd9749606e2e1ef6d1ffed3c7cd34db69c85;hb=7888f570d4b32b447622e25c38a4e78197cc7732;hp=97c098ff8ae6716db18fe94ecd8df132fdb0e722;hpb=a9e0195cd866692844586002f1614ff74a79426a;p=scheme.forth.jl.git diff --git a/scheme-primitives.4th b/scheme-primitives.4th index 97c098f..86fbbd9 100644 --- a/scheme-primitives.4th +++ b/scheme-primitives.4th @@ -352,7 +352,10 @@ hide relcfa pad swap load ; make-primitive load -' read make-primitive read +:noname ( args -- obj ) + 0 ensure-arg-count + read +; make-primitive read defer display :noname ( args -- none ) @@ -367,19 +370,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 +403,7 @@ defer display 2dup 1 ensure-arg-count car string-type ensure-arg-type - (printstring) + displaystring none ; make-primitive display-string @@ -428,3 +443,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