Misc cleanup. Move *host-language* to stepA.
authorJoel Martin <github@martintribe.org>
Sat, 3 Jan 2015 05:33:50 +0000 (23:33 -0600)
committerJoel Martin <github@martintribe.org>
Fri, 9 Jan 2015 22:16:55 +0000 (16:16 -0600)
12 files changed:
clojure/src/step9_try.clj
docs/TODO
docs/step_notes.txt
docs/steps/stepA_interop.txt
docs/steps/stepA_interop2.txt
make/step9_try.mk
mal/step9_try.mal
ps/step9_try.ps
ps/stepA_interop.ps
r/step9_try.r
ruby/reader.rb
ruby/step9_try.rb

index 4990d75..7e18a74 100644 (file)
 (env/env-set repl-env '*ARGV* ())
 
 ;; core.mal: defined using the language itself
-(rep "(def! *host-language* \"clojure\")")
 (rep "(def! not (fn* [a] (if a false true)))")
 (rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
 (rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
   (if args
     (rep (str "(load-file \"" (first args) "\")"))
     (do
-      (rep "(println (str \"Mal [\" *host-language* \"]\"))")
       (repl-loop))))
index 4403cd8..5f379e2 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -1,15 +1,22 @@
 All:
-    - add license file
-    - add re (with rep) and use that (to avoid printing)
-    - keyword type (with hash-map key support)
-    - remove conj and sequential? as necessary elements
+    * keyword type (with hash-map key support)
+    - change perf test to run for 10 seconds and then calculate number
+      of iterations per second
     - redefine (defmacro!) as (def! (macro*))
+    - runtest expect fixes:
+        - stop using expect, so we can drop --raw option
+        - fix long lines in runtext/expect
+    - add license file
+    - add re (use in rep) everywhere and use that (to avoid printing)
+    - move conj and sequential? to core.mal
     - Move *host-language* from step9 to stepA
     - Implement/fix interop: C#, Java, Mal, PHP, Postscript, Ruby
-    - fix long lines in runtext/expect
     - regular expression matching in runtest
     - Print full exception when test gets EOF from expect
 
+    - protocols!
+        - https://github.com/pixie-lang/pixie
+
     - Break out impl eval into step0.5
     - Fix quasiquoting of vectors
 
@@ -36,8 +43,10 @@ C:
     - GC
 
 C#:
+    - fix command line arg processing (doesn't run file specified)
 
 Clojure:
+    - make indent consistent across steps (e.g. step5, step8)
 
 CoffeeScript:
     - make target to compile to JS
@@ -47,6 +56,8 @@ Go:
         https://gobyexample.com/variadic-functions
 
 Haskell:
+    - TCO using seq/bang patterns:
+      http://stackoverflow.com/questions/9149183/tail-optimization-guarantee-loop-encoding-in-haskell
 
 Java:
     - Use gradle instead of mvn
@@ -56,6 +67,8 @@ Javascript:
     - interop: callbacks using Mal functions
 
 Make:
+    - large number handling (move away from peano)
+        - then fix time-ms/perf.mal
     - allow '_' in make variable names
     - Fix: make -f stepA_interop.mk ../mal/step6_file.mal
         (slurp "../tests/incA.mal")
@@ -74,31 +87,24 @@ PHP:
 
 Postscript:
     - add negative numbers
+    - fix blank line after comments
 
 Python:
     - error: python ../python/stepA_interop.py ../mal/stepA_interop.mal ../mal/stepA_interop.mal
     - interop tests
 
 R:
+    - Links:
+        - https://stat.ethz.ch/R-manual/R-devel/library/base/html/readline.html
+        - http://dssm.unipa.it/CRAN/web/packages/rdyncall/rdyncall.pdf
+        - http://www.dyncall.org/docs/FFI.pdf
     - tracebacks in errors
+    - fix running from different directory
 
 Ruby:
 
 Rust:
-    - use built-in regex once fixed:
-        https://github.com/rust-lang/rust/issues/18034
-        https://github.com/rust-lang/rust/issues/18035
-
-VB.Net
-    - convert readline.cs to readline.vb
-
-
----------------------------------------------
-
-
-Future Implementations:
-
-    * Rust:
+    - Links:
         - http://doc.rust-lang.org/index.html
         - http://doc.rust-lang.org/intro.html
         - http://doc.rust-lang.org/guide.html
@@ -115,30 +121,60 @@ Future Implementations:
         - https://github.com/shaleh/rust-readline/blob/master/src/lib.rs
         - http://stackoverflow.com/questions/23942627/does-rust-0-10-have-a-rl-package
         - http://blog.skylight.io/rust-means-never-having-to-close-a-socket/
-    * R
-        - https://stat.ethz.ch/R-manual/R-devel/library/base/html/readline.html
-        - http://dssm.unipa.it/CRAN/web/packages/rdyncall/rdyncall.pdf
-        - http://www.dyncall.org/docs/FFI.pdf
+    - use built-in regex once fixed:
+        https://github.com/rust-lang/rust/issues/18034
+        https://github.com/rust-lang/rust/issues/18035
+
+Racket
+    - metadata on collections
+
+Scala
+    - aptitude install scala
+    - http://learnxinyminutes.com/docs/scala/
+    - readline
+
+VB.Net
+    - aptitude install mono-vbnc
+    - http://www.codeproject.com/Articles/9978/Complete-Comparison-for-VB-NET-and-C
+    - http://msdn.microsoft.com/en-us/library/8hb2a397.aspx
+    - convert readline.cs to readline.vb
+
+
+---------------------------------------------
+
+
+Future Implementations:
+
+    - Ada (gnat)
+        - http://rosettacode.org/wiki/Regular_expressions#Ada
+
+    - C++
 
     - Groovy
         - http://groovy-lang.org/learn.html
         - http://groovy-lang.org/structure.html
 
-    - Scala
-        - aptitude install scala
-        - http://learnxinyminutes.com/docs/scala/
+    - Erlang
+
+    - F#
 
-    - Visual Basic
-        aptitude install mono-vbnc
+    - Haxe
+        - http://api.haxe.org/
+        - http://haxe.us/haxe_tutorial.html
+
+    - Lua
+
+    - Objective-C:
+
+    - Pascal:
+        sudo aptitude install fp-compiler-2.6.2
 
     - VimL
         - https://github.com/tpope/timl
 
+    - Tcl
+
     - TeX/LaTeX
         - Basic interpreter in TeX: http://ctanhg.scharrer-online.de/pkg/basix.html
         - Cheat Sheet: http://www.stdout.org/~winston/latex/latexsheet.pd
         - latex '\nonstopmode\input' blah.tex
-
-    - VB.Net
-        http://www.codeproject.com/Articles/9978/Complete-Comparison-for-VB-NET-and-C
-        http://msdn.microsoft.com/en-us/library/8hb2a397.aspx
index 84962b9..f36575d 100644 (file)
@@ -339,7 +339,7 @@ Step Notes:
         - add nth, first, and rest to core.ns
         - make test^go^step8 should now pass
 
-- stepA_try
+- step9_try
     - core module:
         - throw function
         - apply, map functions: should not directly call EVAL, which
index 9657468..c909056 100644 (file)
@@ -1,4 +1,4 @@
---- step9_try -----------------------------------
+--- stepA_interop -------------------------------
 import types, reader, printer, env, core
 
 READ(str): return reader.read_str(str)
index 1273411..05dfe8c 100644 (file)
@@ -1,4 +1,4 @@
---- step9_try -----------------------------------
+--- stepA_interop -------------------------------
 import types, reader, printer, env, core
 
 READ(str): return reader.read_str(str)
index 1474302..587f400 100644 (file)
@@ -166,7 +166,6 @@ _argv := $(call _list)
 REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv))
 
 # core.mal: defined in terms of the language itself
-$(call do,$(call REP, (def! *host-language* "make") ))
 $(call do,$(call REP, (def! not (fn* (a) (if a false true))) ))
 $(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) ))
 $(call do,$(call REP, (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs))))))) ))
@@ -180,9 +179,7 @@ $(if $(MAKECMDGOALS),\
   $(eval INTERACTIVE :=),)
 
 # repl loop
-$(if $(strip $(INTERACTIVE)),\
-  $(call do,$(call REP, (println (str "Mal [" *host-language* "]")) )) \
-  $(call REPL))
+$(if $(strip $(INTERACTIVE)),$(call REPL))
 
 .PHONY: none $(MAKECMDGOALS)
 none $(MAKECMDGOALS):
index 3e2a258..ac54cef 100644 (file)
 (env-set repl-env '*ARGV* (rest *ARGV*))
 
 ;; core.mal: defined using the new language itself 
-(rep (str "(def! *host-language* \"" *host-language* "-mal\")"))
 (rep "(def! not (fn* [a] (if a false true)))")
 (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
 (rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
 (def! -main (fn* [& args] 
   (if (> (count args) 0)
     (rep (str "(load-file \"" (first args) "\")"))
-    (do
-      (rep "(println (str \"Mal [\" *host-language* \"]\"))")
-      (repl-loop)))))
+    (repl-loop))))
 (apply -main *ARGV*)
index 9c5c240..d9beec7 100644 (file)
@@ -244,7 +244,6 @@ core_ns { _function _ref } forall
 (*ARGV*) [ ] _list_from_array _ref
 
 % core.mal: defined using the language itself
-(\(def! *host-language* "postscript"\)) RE pop
 (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop
 (\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop
 (\(defmacro! cond \(fn* \(& xs\) \(if \(> \(count xs\) 0\) \(list 'if \(first xs\) \(if \(> \(count xs\) 1\) \(nth xs 1\) \(throw "odd number of forms to cond"\)\) \(cons 'cond \(rest \(rest xs\)\)\)\)\)\)\)) RE pop
@@ -261,7 +260,6 @@ userdict /ARGUMENTS known { %if command line arguments
 } if
 
 % repl loop
-(\(println \(str "Mal [" *host-language* "]"\)\)) RE pop
 { %loop
     (user> ) _readline
     not { exit } if  % exit if EOF
index a24ee28..c879294 100644 (file)
@@ -150,8 +150,10 @@ end } def
             {
                 token not { exit } if
                 exch
+                count stackcnt sub 1 roll % send leftover string to bottom
+                exec
+                count stackcnt sub -1 roll % bring leftover string to top
             } loop
-            exec
             count stackcnt gt { % if new operands on stack
                 % return an list of new operands
                 count stackcnt sub array astore
index e699048..02a6507 100644 (file)
@@ -166,7 +166,6 @@ Env.set(repl_env, "eval", function(ast) EVAL(ast, repl_env))
 Env.set(repl_env, "*ARGV*", new.list())
 
 # core.mal: defined using the language itself
-. <- rep("(def! *host-language* \"R\")")
 . <- rep("(def! not (fn* (a) (if a false true)))")
 . <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
 . <- rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
@@ -184,7 +183,6 @@ if (length(args) > 0) {
     quit(save="no", status=0)
 }
 
-. <- rep("(println (str \"Mal [\" *host-language* \"]\"))")
 repeat {
     line <- readline("user> ")
     if (is.null(line)) { cat("\n"); break }
index eb9ae7b..641e65c 100644 (file)
@@ -31,7 +31,7 @@ def read_atom(rdr)
     return case token
         when /^-?[0-9]+$/ then       token.to_i # integer
         when /^-?[0-9][0-9.]*$/ then token.to_f # float
-        when /^"/ then               parse_str(token) # string
+        when /^".*"$/ then           parse_str(token) # string
         when /^:/ then               "\u029e" + token[1..-1] # keyword
         when "nil" then              nil
         when "true" then             true
@@ -57,7 +57,6 @@ def read_list(rdr, klass, start="(", last =")")
 end
 
 def read_form(rdr)
-    token = rdr.peek
     return case rdr.peek
         when ";" then  nil
         when "'" then  rdr.next; List.new [:quote, read_form(rdr)]
index eecba9c..74d0f59 100644 (file)
@@ -155,7 +155,6 @@ repl_env.set(:eval, lambda {|ast| EVAL(ast, repl_env)})
 repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || []))
 
 # core.mal: defined using the language itself
-RE["(def! *host-language* \"ruby\")"]
 RE["(def! not (fn* (a) (if a false true)))"]
 RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]
 RE["(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"]
@@ -167,7 +166,6 @@ if ARGV.size > 0
 end
 
 # repl loop
-RE["(println (str \"Mal [\" *host-language* \"]\"))"]
 while line = _readline("user> ")
     begin
         puts REP[line]