OCaml: put macro flag in metadata rather than special type field
[jackhill/mal.git] / ps / step5_tco.ps
index 802f3d3..680c359 100644 (file)
@@ -1,8 +1,9 @@
-(types.ps) run
-(reader.ps) run
-(printer.ps) run
-(env.ps) run
-(core.ps) run
+/runlibfile where { pop }{ /runlibfile { run } def } ifelse % 
+(types.ps) runlibfile
+(reader.ps) runlibfile
+(printer.ps) runlibfile
+(env.ps) runlibfile
+(core.ps) runlibfile
 
 % read
 /_readline { print flush (%stdin) (r) file 99 string readline } def
@@ -65,7 +66,9 @@ end } def
                     env_set
                     pop % discard the return value
             } for
-            a2 let_env EVAL
+            a2
+            let_env
+            /loop? true def % loop
         }{ /do a0 eq { %if do
             ast _count 2 gt { %if ast has more than 2 elements
                 ast 1 ast _count 2 sub _slice env eval_ast pop
@@ -121,13 +124,16 @@ end } def
 
 /RE { READ repl_env EVAL } def
 /REP { READ repl_env EVAL PRINT } def
-/_ref { _function repl_env 3 1 roll env_set pop } def
 
-core_ns { _ref } forall
+% core.ps: defined using postscript
+/_ref { repl_env 3 1 roll env_set pop } def
+core_ns { _function _ref } forall
 
+% core.mal: defined using the language itself
 (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop
 
-{ % loop
+% repl loop
+{ %loop
     (user> ) _readline
     not { exit } if  % exit if EOF