X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=scheme-primitives.4th;h=e5a7dba89f4189877e6ce6dfb21f79e40286f236;hb=61f902750c854d52bc37a5903e07b7e84f7081c4;hp=56ecab0e5fb3c3d6f0bfa2248dd3649e74e49bc6;hpb=7e44c5ca79a16106aefa315ccf38e74dcd365554;p=scheme.forth.jl.git diff --git a/scheme-primitives.4th b/scheme-primitives.4th index 56ecab0..e5a7dba 100644 --- a/scheme-primitives.4th +++ b/scheme-primitives.4th @@ -354,7 +354,8 @@ hide relcfa ' read make-primitive read -:noname ( args -- ) +defer display +:noname ( args -- none ) 2dup 1 ensure-arg-count car print cr @@ -362,10 +363,68 @@ hide relcfa none ; make-primitive write +: displaypair ( pairobj -- ) + 2dup + car display + cdr + nil-type istype? if 2drop exit then + pair-type istype? if space recurse exit then + ." . " display +; + +: displaychar ( charobj -- ) + drop emit +; + +:noname ( obj -- ) + pair-type istype? if ." (" displaypair ." )" exit then + character-type istype? if displaychar exit then + string-type istype? if (printstring) exit then + + print +; is display + +:noname ( args -- none ) + 2dup 1 ensure-arg-count + car string-type ensure-arg-type + + (printstring) cr + + none +; make-primitive display-string + +:noname ( args -- none ) + 2dup 1 ensure-arg-count + car character-type ensure-arg-type + + displaychar cr + + none +; make-primitive display-character + +:noname ( args -- none ) + 2dup 1 ensure-arg-count + car + + display cr + + none +; make-primitive display + +:noname ( args -- none ) + 0 ensure-arg-count + + cr + + none +; make-primitive newline + ( ==== Evaluation ==== ) -:noname - \ Dummy apply procedure - \ Should never actually run! - ." Error: Dummy apply procedure executed!" cr -; make-primitive apply +:noname ( args -- result ) + 2dup car 2swap cdr + + nil? false = if car then ( proc argvals ) + + apply +; make-primitive apply