4 include term-colours.4th
6 include catch-throw.4th
28 make-type boolean-type
29 make-type character-type
35 make-type primitive-proc-type
36 make-type compound-proc-type
37 make-type fileport-type
38 : istype? ( obj type -- obj bool )
43 \ ---- Exceptions ---- {{{
45 variable nextexception
48 create nextexception @ ,
52 make-exception recoverable-exception
53 make-exception unrecoverable-exception
55 : display-exception-msg ( addr count -- )
68 ['] display-exception-msg ,
76 \ ---- List-structured memory ---- {{{
78 10000 constant scheme-memsize
80 create car-cells scheme-memsize allot
81 create car-type-cells scheme-memsize allot
82 create cdr-cells scheme-memsize allot
83 create cdr-type-cells scheme-memsize allot
85 create nextfrees scheme-memsize allot
96 nextfrees nextfree @ + @
99 nextfree @ scheme-memsize >= if
103 nextfree @ scheme-memsize >= if
104 unrecoverable-exception throw s" Out of memory!"
108 : cons ( car-obj cdr-obj -- pair-obj )
109 cdr-type-cells nextfree @ + !
110 cdr-cells nextfree @ + !
111 car-type-cells nextfree @ + !
112 car-cells nextfree @ + !
118 : car ( pair-obj -- car-obj )
120 dup car-cells + @ swap
124 : cdr ( pair-obj -- car-obj )
126 dup cdr-cells + @ swap
130 : set-car! ( obj pair-obj -- )
132 rot swap car-type-cells + !
136 : set-cdr! ( obj pair-obj -- )
138 rot swap cdr-type-cells + !
143 : nil? nil-type istype? ;
146 : none? none-type istype? ;
148 : objvar create nil swap , , ;
150 : value@ ( objvar -- val ) @ ;
151 : type@ ( objvar -- type ) 1+ @ ;
152 : value! ( newval objvar -- ) ! ;
153 : type! ( newtype objvar -- ) 1+ ! ;
154 : obj! ( newobj objvar -- ) dup rot swap 1+ ! ! ;
155 : obj@ ( objvar -- obj ) dup @ swap 1+ @ ;
157 : objeq? ( obj obj -- bool )
160 : 2rot ( a1 a2 b1 b2 c1 c2 -- b1 b2 c1 c2 a1 a2 )
161 >R >R ( a1 a2 b1 b2 )
162 2swap ( b1 b2 a1 a2 )
163 R> R> ( b1 b2 a1 a2 c1 c2 )
167 : -2rot ( a1 a2 b1 b2 c1 c2 -- c1 c2 a1 a2 b1 b2 )
168 2swap ( a1 a2 c1 c2 b1 b2 )
169 >R >R ( a1 a2 c1 c2 )
170 2swap ( c1 c2 a1 a2 )
176 \ ---- Port I/O ---- {{{
178 : fileport>fid ( fileport -- fid )
181 : fid>fileport ( fid -- fileport )
184 : open-input-file ( addr n -- fileport )
185 r/o open-file drop fid>fileport
188 : close-port ( fileport -- )
189 fileport>fid close-file drop
192 objvar console-i/o-port
193 0 fileport-type console-i/o-port obj!
195 objvar current-input-port
196 console-i/o-port obj@ current-input-port obj!
198 : read-port ( fileport -- obj )
199 current-input-port obj!
202 : read-console ( -- obj )
203 console-i/o-port obj@ read-port ;
207 \ ---- Pre-defined symbols ---- {{{
211 : duplicate-charlist ( charlist -- copy )
213 2dup car 2swap cdr recurse cons
216 : charlist-equiv ( charlist charlist -- bool )
225 2drop 2drop true exit
227 2drop 2drop false exit
232 2drop 2drop false exit
239 car drop -rot car drop = if
240 cdr 2swap cdr recurse
246 : charlist>symbol ( charlist -- symbol-obj )
265 drop symbol-type 2dup
266 symbol-table obj@ cons
271 : cstr>charlist ( addr n -- charlist )
275 2dup drop @ character-type 2swap
283 : create-symbol ( -- )
291 does> dup @ swap 1+ @
294 create-symbol quote quote-symbol
295 create-symbol quasiquote quasiquote-symbol
296 create-symbol unquote unquote-symbol
297 create-symbol unquote-splicing unquote-splicing-symbol
298 create-symbol define define-symbol
299 create-symbol define-macro define-macro-symbol
300 create-symbol set! set!-symbol
301 create-symbol ok ok-symbol
302 create-symbol if if-symbol
303 create-symbol lambda lambda-symbol
304 create-symbol λ λ-symbol
305 create-symbol begin begin-symbol
309 \ ---- Environments ---- {{{
311 : enclosing-env ( env -- env )
314 : first-frame ( env -- frame )
317 : make-frame ( vars vals -- frame )
320 : frame-vars ( frame -- vars )
323 : frame-vals ( frame -- vals )
326 : add-binding ( var val frame -- )
327 2swap 2over frame-vals cons
329 2swap 2over frame-vars cons
333 : extend-env ( vars vals env -- env )
343 : get-vars-vals-frame ( var frame -- bool )
344 2dup frame-vars vars obj!
348 vars obj@ nil objeq? false =
350 2dup vars obj@ car objeq? if
355 vars obj@ cdr vars obj!
356 vals obj@ cdr vals obj!
362 : get-vars-vals ( var env -- vars? vals? bool )
367 2over 2over first-frame
368 get-vars-vals-frame if
370 vars obj@ vals obj@ true
384 : lookup-var ( var env -- val )
388 recoverable-exception throw" Tried to read unbound variable."
392 : set-var ( var val env -- )
393 >R >R 2swap R> R> ( val var env )
395 2swap 2drop ( val vals )
398 recoverable-exception throw" Tried to set unbound variable."
404 : define-var ( var val env -- )
407 2over env obj@ ( var val var env )
409 2swap 2drop ( var val vals )
414 first-frame ( var val frame )
421 : make-procedure ( params body env -- proc )
424 drop compound-proc-type
428 nil nil nil extend-env
433 \ ---- Primitives ---- {{{
435 : make-primitive ( cfa -- )
442 rot primitive-proc-type ( var prim )
443 global-env obj@ define-var
446 : ensure-arg-count ( args n -- )
448 drop nil objeq? false = if
449 recoverable-exception throw" Too many arguments for primitive procedure."
453 recoverable-exception throw" Too few arguments for primitive procedure."
460 : ensure-arg-type-and-count ( tn tn-1 ... t2 t1 args n -- )
462 drop nil objeq? false = if
463 recoverable-exception throw" Too many arguments for primitive procedure."
467 recoverable-exception throw" Too few arguments for primitive procedure."
470 2dup cdr 2swap car ( ... t1 n args' arg1 )
471 2rot 1- swap 2swap rot ( ... args' n-1 arg1 t1 )
473 recoverable-exception throw" Incorrect type for primitive procedure."
481 : push-args-to-stack ( args -- arg1 arg2 ... argn )
491 : add-fa-checks ( cfa n -- cfa' )
492 here current @ 1+ dup @ , !
496 ['] 2dup , ['] lit , , ['] ensure-arg-count ,
497 ['] push-args-to-stack ,
498 ['] lit , , ['] execute ,
502 : add-fa-type-checks ( cfa t1 t2 ... tn n -- cfa' )
503 here current @ 1+ dup @ , !
510 dup ( cfa t1 t2 ... tn n m )
515 rot ['] lit , , ( cfa t1 t2 ... tn-1 n m )
521 ['] lit , , ['] ensure-arg-type-and-count ,
523 ['] push-args-to-stack ,
524 ['] lit , , ['] execute ,
530 : make-fa-primitive ( cfa n -- )
531 add-fa-checks make-primitive ;
533 : make-fa-type-primitive ( cfa t1 t2 ... tn n -- )
534 add-fa-type-checks make-primitive ;
537 bold fg red ." Incorrect argument type." reset-term cr
541 : ensure-arg-type ( arg type -- arg )
543 recoverable-exception throw" Incorrect argument type for primitive procedure."
550 \ ---- Macros ---- {{{
554 ( Look up macro in macro table. Returns nil if
556 : lookup-macro ( name_symbol -- proc )
575 : make-macro ( name_symbol params body env -- )
578 2swap ( proc name_symbol )
585 2over 2over ( proc name table name table )
587 2swap 2drop ( proc table )
599 macro-table obj@ cons
608 variable stored-parse-idx
609 create parse-str 161 allot
610 variable parse-str-span
612 create parse-idx-stack 10 allot
613 variable parse-idx-sp
614 parse-idx-stack parse-idx-sp !
617 parse-idx @ parse-idx-sp @ !
622 parse-idx-sp @ parse-idx-stack <= abort" Parse index stack underflow."
626 parse-idx-sp @ @ parse-idx ! ;
630 '\n' parse-str parse-str-span @ + !
631 1 parse-str-span +! ;
634 4 parse-str parse-str-span @ + !
635 1 parse-str-span +! ;
642 current-input-port obj@ console-i/o-port obj@ objeq? if
643 parse-str 160 expect cr
644 span @ parse-str-span !
646 parse-str 160 current-input-port obj@ fileport>fid read-line
647 drop swap parse-str-span !
649 parse-str-span @ 0= and if append-eof then
660 : charavailable? ( -- bool )
661 parse-str-span @ parse-idx @ > ;
663 : nextchar ( -- char )
664 charavailable? false = if getline then
665 parse-str parse-idx @ + @ ;
668 : whitespace? ( -- bool )
680 nextchar [char] ( = or
681 nextchar [char] ) = or
684 : commentstart? ( -- bool )
685 nextchar [char] ; = ;
689 false \ Indicates whether or not we're eating a comment
692 dup whitespace? or commentstart? or
694 dup nextchar '\n' = and if
695 invert \ Stop eating comment
697 dup false = commentstart? and if
698 invert \ Begin eating comment
713 nextchar [char] - = ;
716 nextchar [char] + = ;
718 : fixnum? ( -- bool )
744 : flonum? ( -- bool )
751 \ Record starting parse idx:
752 \ Want to detect whether any characters (following +/-) were eaten.
759 [char] . nextchar = if
766 [char] e nextchar = [char] E nextchar = or if
774 drop pop-parse-idx false exit
782 \ This is a real number if characters were
783 \ eaten and the next characer is a delimiter.
784 parse-idx @ < delim? and
789 : boolean? ( -- bool )
790 nextchar [char] # <> if false exit then
797 and if pop-parse-idx false exit then
809 : str-equiv? ( str -- bool )
826 delim? false = if drop false then
831 : character? ( -- bool )
832 nextchar [char] # <> if false exit then
837 nextchar [char] \ <> if pop-parse-idx false exit then
841 S" newline" str-equiv? if pop-parse-idx true exit then
842 S" space" str-equiv? if pop-parse-idx true exit then
843 S" tab" str-equiv? if pop-parse-idx true exit then
845 charavailable? false = if pop-parse-idx false exit then
851 nextchar [char] ( = ;
853 : string? ( -- bool )
854 nextchar [char] " = ;
856 : readfixnum ( -- fixnum )
867 10 * nextchar [char] 0 - +
876 : readflonum ( -- flonum )
880 [char] . nextchar = if
886 nextchar [char] 0 - i->f ( f exp d )
887 over f/ rot f+ ( exp f' )
888 swap 10.0 f* ( f' exp' )
895 [char] e nextchar = [char] E nextchar = or if
909 : readbool ( -- bool-obj )
912 nextchar [char] f = if
923 : readchar ( -- char-obj )
927 S" newline" str-equiv? if 7 parse-idx +! '\n' character-type exit then
928 S" space" str-equiv? if 5 parse-idx +! bl character-type exit then
929 S" tab" str-equiv? if 3 parse-idx +! 9 character-type exit then
931 nextchar character-type
936 : readstring ( -- charlist )
937 nextchar [char] " = if
942 ." No delimiter following right double quote. Aborting." cr
951 nextchar [char] \ = if
954 [char] n of '\n' endof
955 [char] " of [char] " endof
961 inc-parse-idx character-type
968 : readsymbol ( -- charlist )
969 delim? if nil exit then
971 nextchar inc-parse-idx character-type
978 : readpair ( -- pairobj )
982 nextchar [char] ) = if
987 ." No delimiter following right paren. Aborting." cr
996 \ Read first pair element
1001 nextchar [char] . = if
1006 ." No delimiter following '.'. Aborting." cr
1020 \ Parse a scheme expression
1051 nextchar [char] " <> if
1052 bold red ." Missing closing double-quote." reset-term cr
1070 nextchar [char] ) <> if
1071 bold red ." Missing closing paren." reset-term cr
1080 nextchar [char] ' = if
1082 quote-symbol recurse nil cons cons exit
1085 nextchar [char] ` = if
1087 quasiquote-symbol recurse nil cons cons exit
1090 nextchar [char] , = if
1092 nextchar [char] @ = if
1094 unquote-splicing-symbol recurse nil cons cons exit
1096 unquote-symbol recurse nil cons cons exit
1106 \ Anything else is parsed as a symbol
1107 readsymbol charlist>symbol
1109 \ Replace λ with lambda
1110 2dup λ-symbol objeq? if
1119 \ ---- Eval ---- {{{
1121 : self-evaluating? ( obj -- obj bool )
1122 boolean-type istype? if true exit then
1123 fixnum-type istype? if true exit then
1124 flonum-type istype? if true exit then
1125 character-type istype? if true exit then
1126 string-type istype? if true exit then
1127 nil-type istype? if true exit then
1128 none-type istype? if true exit then
1133 : tagged-list? ( obj tag-obj -- obj bool )
1135 pair-type istype? false = if
1141 : quote? ( obj -- obj bool )
1142 quote-symbol tagged-list? ;
1144 : quote-body ( quote-obj -- quote-body-obj )
1147 : quasiquote? ( obj -- obj bool )
1148 quasiquote-symbol tagged-list? ;
1150 : unquote? ( obj -- obj bool )
1151 unquote-symbol tagged-list? ;
1153 : unquote-splicing? ( obj -- obj bool )
1154 unquote-splicing-symbol tagged-list? ;
1156 : eval-unquote ( env obj -- res )
1160 recoverable-exception throw" no arguments to unquote."
1165 recoverable-exception throw" too many arguments to unquote."
1168 2drop car 2swap eval
1171 ( Create a new list from elements of l1 consed on to l2 )
1172 : join-lists ( l2 l1 -- l3 )
1173 nil? if 2drop exit then
1180 defer eval-quasiquote-item
1181 : eval-quasiquote-pair ( env obj -- res )
1182 2over 2over ( env obj env obj )
1184 cdr eval-quasiquote-item
1186 -2rot car ( cdritem env objcar )
1188 unquote-splicing? if
1189 eval-unquote ( cdritems caritem )
1197 eval-quasiquote-item ( cdritems caritem )
1212 pair-type istype? if
1213 eval-quasiquote-pair exit
1217 ; is eval-quasiquote-item
1219 : eval-quasiquote ( obj env -- res )
1220 2swap cdr ( env args )
1223 recoverable-exception throw" no arguments to quasiquote."
1226 2dup cdr ( env args args-cdr )
1228 recoverable-exception throw" too many arguments to quasiquote."
1231 2drop car ( env arg )
1233 eval-quasiquote-item
1236 : variable? ( obj -- obj bool )
1237 symbol-type istype? ;
1239 : definition? ( obj -- obj bool )
1240 define-symbol tagged-list? ;
1242 : make-lambda ( params body -- lambda-exp )
1243 lambda-symbol -2rot cons cons ;
1245 ( Handles iterative expansion of defines in
1246 terms of nested lambdas. Most Schemes only
1247 handle one iteration of expansion! )
1248 : definition-var-val ( obj -- var val )
1250 cdr 2dup cdr 2swap car ( val var )
1253 symbol-type istype? false =
1255 2dup cdr 2swap car ( val formals var' )
1256 -2rot 2swap ( var' formals val )
1257 make-lambda nil cons ( var' val' )
1264 : eval-definition ( obj env -- res )
1265 2dup 2rot ( env env obj )
1266 definition-var-val ( env env var val )
1267 2rot eval ( env var val )
1269 2rot ( var val env )
1275 : assignment? ( obj -- obj bool )
1276 set!-symbol tagged-list? ;
1278 : assignment-var ( obj -- var )
1281 : assignment-val ( obj -- val )
1284 : eval-assignment ( obj env -- res )
1286 2over 2over ( env obj env obj )
1287 assignment-val 2swap ( env obj valexp env )
1288 eval ( env obj val )
1290 2swap assignment-var 2swap ( env var val )
1292 2rot ( var val env )
1298 : macro-definition? ( obj -- obj bool )
1299 define-macro-symbol tagged-list? ;
1301 : macro-definition-name ( exp -- mname )
1304 : macro-definition-params ( exp -- params )
1307 : macro-definition-body ( exp -- body )
1311 : eval-define-macro ( obj env -- res )
1314 2dup macro-definition-name 2swap ( name obj )
1315 2dup macro-definition-params 2swap ( name params obj )
1316 macro-definition-body ( name params body )
1318 env obj@ ( name params body env )
1326 : if? ( obj -- obj bool )
1327 if-symbol tagged-list? ;
1329 : if-predicate ( ifobj -- pred )
1332 : if-consequent ( ifobj -- conseq )
1335 : if-alternative ( ifobj -- alt|none )
1343 : false? ( boolobj -- boolean )
1344 boolean-type istype? if
1345 false boolean-type objeq?
1351 : true? ( boolobj -- bool )
1354 : lambda? ( obj -- obj bool )
1355 lambda-symbol tagged-list? ;
1357 : lambda-parameters ( obj -- params )
1360 : lambda-body ( obj -- body )
1363 : begin? ( obj -- obj bool )
1364 begin-symbol tagged-list? ;
1366 : begin-actions ( obj -- actions )
1369 : eval-sequence ( explist env -- finalexp env )
1370 ( Evaluates all bar the final expressions in
1371 an an expression list. The final expression
1372 is returned to allow for tail optimization. )
1374 2swap ( env explist )
1376 \ Abort on empty list
1383 2dup cdr ( env explist nextexplist )
1386 -2rot car 2over ( nextexplist env exp env )
1388 2drop \ discard result
1389 2swap ( env nextexplist )
1392 2drop car 2swap ( finalexp env )
1395 : application? ( obj -- obj bool )
1398 : operator ( obj -- operator )
1401 : operands ( obj -- operands )
1404 : nooperands? ( operands -- bool )
1407 : first-operand ( operands -- operand )
1410 : rest-operands ( operands -- other-operands )
1413 : list-of-vals ( args env -- vals )
1419 2over 2over first-operand 2swap eval
1420 -2rot rest-operands 2swap recurse
1425 : procedure-params ( proc -- params )
1426 drop pair-type car ;
1428 : procedure-body ( proc -- body )
1429 drop pair-type cdr car ;
1431 : procedure-env ( proc -- body )
1432 drop pair-type cdr cdr car ;
1434 ( Ensure terminating symbol arg name is handled
1435 specially to allow for variadic procedures. )
1436 : flatten-proc-args ( argvals argnames -- argvals' argnames' )
1438 2over nil? false = if
1439 recoverable-exception throw" Too many arguments for compound procedure."
1446 symbol-type istype? if
1456 recoverable-exception throw" Too few arguments for compound procedure."
1463 recurse ( argvals argnames argvals'' argnames'' )
1464 2rot car 2swap cons ( argvals argvals'' argnames' )
1465 2rot car 2rot cons ( argnames' argvals' )
1469 : apply ( proc argvals -- result )
1471 primitive-proc-type of
1475 compound-proc-type of
1476 2dup procedure-body ( argvals proc body )
1477 -2rot 2dup procedure-params ( body argvals proc argnames )
1478 -2rot procedure-env ( body argnames argvals procenv )
1484 extend-env ( body env )
1488 R> drop ['] eval goto-deferred \ Tail call optimization
1491 recoverable-exception throw" Object not applicable."
1495 ( Simply evaluates the given procedure with expbody as its argument. )
1496 : macro-expand ( proc expbody -- result )
1498 2dup procedure-body ( expbody proc procbody )
1499 -2rot 2dup procedure-params ( procbody expbody proc argnames )
1500 -2rot procedure-env ( procbody argnames expbody procenv )
1506 extend-env eval-sequence eval
1509 :noname ( obj env -- result )
1524 2swap eval-quasiquote
1534 2swap eval-definition
1539 2swap eval-assignment
1543 macro-definition? if
1544 2swap eval-define-macro
1560 ['] eval goto-deferred
1564 2dup lambda-parameters
1573 ['] eval goto-deferred
1578 2over 2over ( env exp env exp )
1579 operator ( env exp env opname )
1581 2dup lookup-macro nil? false = if
1582 \ Macro function evaluation
1584 ( env exp env opname mproc )
1585 2swap 2drop -2rot 2drop cdr ( env mproc body )
1590 ['] eval goto-deferred
1592 \ Regular function application
1594 2drop ( env exp env opname )
1596 2swap eval ( env exp proc )
1598 -2rot ( proc env exp )
1599 operands 2swap ( proc operands env )
1600 list-of-vals ( proc argvals )
1607 recoverable-exception throw" Tried to evaluate object with unknown type."
1612 \ ---- Print ---- {{{
1614 : printfixnum ( fixnum -- ) drop 0 .R ;
1616 : printflonum ( flonum -- ) drop f. ;
1618 : printbool ( bool -- )
1626 : printchar ( charobj -- )
1629 9 of ." #\tab" endof
1630 bl of ." #\space" endof
1631 '\n' of ." #\newline" endof
1637 : (printstring) ( stringobj -- )
1638 nil? if 2drop exit then
1642 '\n' of ." \n" drop endof
1643 [char] \ of ." \\" drop endof
1644 [char] " of [char] \ emit [char] " emit drop endof
1650 : printstring ( stringobj -- )
1655 : printsymbol ( symbolobj -- )
1656 nil-type istype? if 2drop exit then
1662 : printnil ( nilobj -- )
1665 : printpair ( pairobj -- )
1669 nil-type istype? if 2drop exit then
1670 pair-type istype? if space recurse exit then
1674 : printprim ( primobj -- )
1675 2drop ." <primitive procedure>" ;
1677 : printcomp ( primobj -- )
1678 2drop ." <compound procedure>" ;
1680 : printnone ( noneobj -- )
1681 2drop ." Unspecified return value" ;
1683 : printport ( port -- )
1687 fixnum-type istype? if printfixnum exit then
1688 flonum-type istype? if printflonum exit then
1689 boolean-type istype? if printbool exit then
1690 character-type istype? if printchar exit then
1691 string-type istype? if printstring exit then
1692 symbol-type istype? if printsymbol exit then
1693 nil-type istype? if printnil exit then
1694 pair-type istype? if ." (" printpair ." )" exit then
1695 primitive-proc-type istype? if printprim exit then
1696 compound-proc-type istype? if printcomp exit then
1697 none-type istype? if printnone exit then
1699 recoverable-exception throw" Tried to print object with unknown type."
1704 \ ---- Garbage Collection ---- {{{
1709 variable gc-stack-depth
1712 depth gc-stack-depth !
1716 false gc-enabled ! ;
1721 : pairlike? ( obj -- obj bool )
1722 pair-type istype? if true exit then
1723 string-type istype? if true exit then
1724 symbol-type istype? if true exit then
1725 compound-proc-type istype? if true exit then
1730 : pairlike-marked? ( obj -- obj bool )
1731 over nextfrees + @ 0=
1734 : mark-pairlike ( obj -- obj )
1735 over nextfrees + 0 swap !
1744 : gc-mark-obj ( obj -- )
1746 pairlike? invert if 2drop exit then
1747 pairlike-marked? if 2drop exit then
1758 scheme-memsize nextfree !
1759 0 scheme-memsize 1- do
1760 nextfrees i + @ 0<> if
1761 nextfree @ nextfrees i + !
1767 \ Following a GC, this gives the amount of free memory
1771 nextfrees i + @ 0= if 1+ then
1775 \ Debugging word - helps spot memory that is retained
1778 nextfrees i + @ 0<> if
1790 symbol-table obj@ gc-mark-obj
1791 macro-table obj@ gc-mark-obj
1792 global-env obj@ gc-mark-obj
1794 depth gc-stack-depth @ do
1803 \ ." (" gc-count-marked . ." pairs marked as used.)" cr
1804 ; is collect-garbage
1808 \ ---- Loading files ---- {{{
1810 : charlist>cstr ( charlist addr -- n )
1812 dup 2swap ( origaddr addr charlist )
1818 drop ( origaddr addr charlist char )
1819 -rot 2swap ( origaddr charlist addr char )
1821 1+ -rot ( origaddr nextaddr charlist )
1824 2drop ( origaddr finaladdr )
1828 : load ( addr n -- finalResult )
1833 ok-symbol ( port res )
1836 2over read-port ( port res obj )
1838 2dup EOF character-type objeq? if
1839 2drop 2swap close-port
1843 2swap 2drop ( port obj )
1845 global-env obj@ eval ( port res )
1851 \ ---- Standard Library ---- {{{
1853 include scheme-primitives.4th
1855 s" scheme-library.scm" load 2drop
1861 ( REPL calls REPL-BODY in a loop until repl-body returns true. )
1862 : repl-body ( -- bool )
1863 cr bold fg green ." > " reset-term
1867 2dup EOF character-type objeq? if
1869 bold fg blue ." Moriturus te saluto." reset-term cr
1873 global-env obj@ eval
1875 fg cyan ." ; " print reset-term
1881 cr ." Welcome to scheme.forth.jl!" cr
1882 ." Use Ctrl-D to exit." cr
1891 recoverable-exception of false endof
1892 unrecoverable-exception of true endof