X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=scheme.4th;h=e1126ff0868bcc7a6bca3bdbefc1889d13a34ad1;hb=7c4b983db5c13783ed581b302becb7e8419123dc;hp=1f2111ab41158161e4c76f1066a396611d920fe1;hpb=9f67194788cd9f6b8b576e31ecb7f3059648a659;p=scheme.forth.jl.git diff --git a/scheme.4th b/scheme.4th index 1f2111a..e1126ff 100644 --- a/scheme.4th +++ b/scheme.4th @@ -3,18 +3,31 @@ scheme definitions include term-colours.4th include defer-is.4th +include throw-catch.4th + +defer read +defer eval +defer print \ ------ Types ------ -0 constant fixnum-type -1 constant boolean-type -2 constant character-type -3 constant string-type -4 constant nil-type -5 constant pair-type -6 constant symbol-type -7 constant primitive-proc-type -8 constant compound-proc-type +variable nexttype +0 nexttype ! +: make-type + create nexttype @ , + nexttype @ 1+ nexttype ! + does> @ ; + +make-type fixnum-type +make-type real-type +make-type boolean-type +make-type character-type +make-type string-type +make-type nil-type +make-type pair-type +make-type symbol-type +make-type primitive-proc-type +make-type compound-proc-type : istype? ( obj type -- obj bool ) over = ; @@ -376,8 +389,6 @@ include scheme-primitives.4th \ ---- Read ---- {{{ -defer read - variable parse-idx variable stored-parse-idx create parse-str 161 allot @@ -785,8 +796,6 @@ parse-idx-stack parse-idx-sp ! \ ---- Eval ---- {{{ -defer eval - : self-evaluating? ( obj -- obj bool ) boolean-type istype? if true exit then fixnum-type istype? if true exit then @@ -981,8 +990,7 @@ defer eval 2drop ( env body ) car 2swap ( exp env ) - ['] eval goto-prime \ Tail call optimization - \ eval \ No tail call optimization + R> drop ['] eval goto-deferred \ Tail call optimization endof bold fg red ." Object not applicable. Aboring." reset-term cr @@ -1030,7 +1038,8 @@ defer eval if-alternative then - 2swap ['] eval goto + 2swap + ['] eval goto-deferred then lambda? if @@ -1058,8 +1067,6 @@ defer eval \ ---- Print ---- {{{ -defer print - : printnum ( numobj -- ) drop 0 .R ; : printbool ( numobj -- )