X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scheme.forth.jl.git;a=blobdiff_plain;f=src%2Fscheme-primitives.4th;h=493f2564ef4971fc3079c2c6aaf004ef62f2b8dd;hp=1ed995b2439a3a5169105dd535f97fe3bd4d9e70;hb=2899e37fdb0ecf89bb949cfcc0a9db2cac54677f;hpb=bc2450b4b29d6bb8ba5422fb9eb7a75d1b6b5a57 diff --git a/src/scheme-primitives.4th b/src/scheme-primitives.4th index 1ed995b..493f256 100644 --- a/src/scheme-primitives.4th +++ b/src/scheme-primitives.4th @@ -46,6 +46,10 @@ -rot 2drop boolean-type ; 1 make-fa-primitive procedure? +:noname ( args -- boolobj ) + port-type istype? -rot 2drop boolean-type +; 1 make-fa-primitive port? + \ }}} \ ==== Type conversions ==== {{{ @@ -471,6 +475,36 @@ current-input-port obj@ ; 0 make-fa-primitive current-input-port +:noname ( args -- charobj ) + nil? if + 2drop current-input-port obj@ + else + car port-type ensure-arg-type + then + + read-char +; make-primitive read-char + +:noname ( args -- charobj ) + nil? if + 2drop current-input-port obj@ + else + car port-type ensure-arg-type + then + + peek-char +; make-primitive peek-char + +:noname ( args -- stringobj ) + nil? if + 2drop current-input-port obj@ + else + car port-type ensure-arg-type + then + + read-line +; make-primitive read-line + : charlist>cstr ( charlist addr -- n ) dup 2swap ( origaddr addr charlist )