X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=scheme.4th;h=19848b60409e957933ac482f72e87dc803f7a6b2;hb=af4ada618d8d096645f783f40508a1bd6ad0d95d;hp=1953cf98cf0ec004d9bbbe7c4a54acc96b93d4f6;hpb=dc6e0cea1e1e982da8029c94d78ee66ab7e8fd82;p=scheme.forth.jl.git diff --git a/scheme.4th b/scheme.4th index 1953cf9..19848b6 100644 --- a/scheme.4th +++ b/scheme.4th @@ -296,6 +296,17 @@ global-env setobj then ; +: arg-type-error + bold fg red ." Incorrect argument type." reset-term cr + abort +; + +: ensure-arg-type ( arg type -- arg ) + istype? false = if + arg-type-error + then +; + include scheme-primitives.4th \ }}} @@ -382,8 +393,11 @@ parse-idx-stack parse-idx-sp ! : minus? ( -- bool ) nextchar [char] - = ; +: plus? ( -- bool ) + nextchar [char] + = ; + : fixnum? ( -- bool ) - minus? if + minus? plus? or if inc-parse-idx delim? if @@ -482,8 +496,11 @@ parse-idx-stack parse-idx-sp ! nextchar [char] " = ; : readnum ( -- num-atom ) - minus? dup if + plus? minus? or if + minus? inc-parse-idx + else + false then 0