aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-01-02 23:33:50 -0600
committerJoel Martin <github@martintribe.org>2015-01-09 16:16:55 -0600
commit96f1845afdb816515bba83ad4bb8fee6bc466557 (patch)
tree6fd8d7949ba26863d17122160a488db216fd1b81
parentf522319598c701efde91a78b07110d7039a8c906 (diff)
downloadmal-96f1845afdb816515bba83ad4bb8fee6bc466557.tar.gz
mal-96f1845afdb816515bba83ad4bb8fee6bc466557.zip
Misc cleanup. Move *host-language* to stepA.
-rw-r--r--clojure/src/step9_try.clj2
-rw-r--r--docs/TODO100
-rw-r--r--docs/step_notes.txt2
-rw-r--r--docs/steps/stepA_interop.txt2
-rw-r--r--docs/steps/stepA_interop2.txt2
-rw-r--r--make/step9_try.mk5
-rw-r--r--mal/step9_try.mal5
-rw-r--r--ps/step9_try.ps2
-rw-r--r--ps/stepA_interop.ps4
-rw-r--r--r/step9_try.r2
-rw-r--r--ruby/reader.rb3
-rw-r--r--ruby/step9_try.rb2
12 files changed, 77 insertions, 54 deletions
diff --git a/clojure/src/step9_try.clj b/clojure/src/step9_try.clj
index 4990d75..7e18a74 100644
--- a/clojure/src/step9_try.clj
+++ b/clojure/src/step9_try.clj
@@ -152,7 +152,6 @@
(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)))))))")
@@ -174,5 +173,4 @@
(if args
(rep (str "(load-file \"" (first args) "\")"))
(do
- (rep "(println (str \"Mal [\" *host-language* \"]\"))")
(repl-loop))))
diff --git a/docs/TODO b/docs/TODO
index 4403cd8..5f379e2 100644
--- 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
diff --git a/docs/step_notes.txt b/docs/step_notes.txt
index 84962b9..f36575d 100644
--- a/docs/step_notes.txt
+++ b/docs/step_notes.txt
@@ -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
diff --git a/docs/steps/stepA_interop.txt b/docs/steps/stepA_interop.txt
index 9657468..c909056 100644
--- a/docs/steps/stepA_interop.txt
+++ b/docs/steps/stepA_interop.txt
@@ -1,4 +1,4 @@
---- step9_try -----------------------------------
+--- stepA_interop -------------------------------
import types, reader, printer, env, core
READ(str): return reader.read_str(str)
diff --git a/docs/steps/stepA_interop2.txt b/docs/steps/stepA_interop2.txt
index 1273411..05dfe8c 100644
--- a/docs/steps/stepA_interop2.txt
+++ b/docs/steps/stepA_interop2.txt
@@ -1,4 +1,4 @@
---- step9_try -----------------------------------
+--- stepA_interop -------------------------------
import types, reader, printer, env, core
READ(str): return reader.read_str(str)
diff --git a/make/step9_try.mk b/make/step9_try.mk
index 1474302..587f400 100644
--- a/make/step9_try.mk
+++ b/make/step9_try.mk
@@ -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):
diff --git a/mal/step9_try.mal b/mal/step9_try.mal
index 3e2a258..ac54cef 100644
--- a/mal/step9_try.mal
+++ b/mal/step9_try.mal
@@ -154,7 +154,6 @@
(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)))))))")
@@ -175,7 +174,5 @@
(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*)
diff --git a/ps/step9_try.ps b/ps/step9_try.ps
index 9c5c240..d9beec7 100644
--- a/ps/step9_try.ps
+++ b/ps/step9_try.ps
@@ -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
diff --git a/ps/stepA_interop.ps b/ps/stepA_interop.ps
index a24ee28..c879294 100644
--- a/ps/stepA_interop.ps
+++ b/ps/stepA_interop.ps
@@ -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
diff --git a/r/step9_try.r b/r/step9_try.r
index e699048..02a6507 100644
--- a/r/step9_try.r
+++ b/r/step9_try.r
@@ -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 }
diff --git a/ruby/reader.rb b/ruby/reader.rb
index eb9ae7b..641e65c 100644
--- a/ruby/reader.rb
+++ b/ruby/reader.rb
@@ -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)]
diff --git a/ruby/step9_try.rb b/ruby/step9_try.rb
index eecba9c..74d0f59 100644
--- a/ruby/step9_try.rb
+++ b/ruby/step9_try.rb
@@ -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]