aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile19
-rw-r--r--README.md6
-rw-r--r--bash/Makefile2
-rwxr-xr-xbash/stepA_mal.sh (renamed from bash/stepA_interop.sh)0
-rw-r--r--bash/tests/stepA_mal.mal (renamed from bash/tests/stepA_interop.mal)0
-rw-r--r--c/Makefile4
-rw-r--r--c/stepA_mal.c (renamed from c/stepA_interop.c)0
-rw-r--r--c/tests/stepA_mal.mal (renamed from c/tests/stepA_interop.mal)0
-rw-r--r--clojure/Makefile2
-rw-r--r--clojure/src/stepA_mal.clj (renamed from clojure/src/stepA_interop.clj)0
-rw-r--r--clojure/tests/stepA_mal.mal (renamed from clojure/tests/stepA_interop.mal)0
-rw-r--r--coffee/Makefile2
-rw-r--r--coffee/stepA_mal.coffee (renamed from coffee/stepA_interop.coffee)0
-rw-r--r--coffee/tests/stepA_mal.mal (renamed from coffee/tests/stepA_interop.mal)0
-rw-r--r--cs/Makefile4
-rw-r--r--cs/stepA_mal.cs (renamed from cs/stepA_interop.cs)6
-rw-r--r--docs/TODO18
-rw-r--r--docs/step_notes.txt2
-rw-r--r--forth/Makefile2
-rw-r--r--forth/stepA_mal.fs (renamed from forth/stepA_interop.fs)0
-rw-r--r--forth/tests/stepA_mal.mal (renamed from forth/tests/stepA_interop.mal)0
-rw-r--r--go/Makefile4
-rw-r--r--go/src/stepA_mal/stepA_mal.go (renamed from go/src/stepA_interop/stepA_interop.go)0
-rw-r--r--haskell/Makefile2
-rw-r--r--haskell/stepA_mal.hs (renamed from haskell/stepA_interop.hs)0
-rw-r--r--java/Makefile2
-rw-r--r--java/pom.xml4
-rw-r--r--java/src/main/java/mal/stepA_mal.java (renamed from java/src/main/java/mal/stepA_interop.java)2
-rw-r--r--js/Makefile2
-rw-r--r--js/stepA_mal.js (renamed from js/stepA_interop.js)8
-rw-r--r--js/tests/stepA_mal.mal (renamed from js/tests/stepA_interop.mal)0
-rw-r--r--js/types.js4
-rw-r--r--lua/Makefile2
-rw-r--r--lua/core.lua2
-rw-r--r--lua/readline.lua9
-rwxr-xr-xlua/step1_read_print.lua4
-rwxr-xr-xlua/step2_eval.lua4
-rwxr-xr-xlua/step3_env.lua4
-rwxr-xr-xlua/step4_if_fn_do.lua4
-rwxr-xr-xlua/step5_tco.lua4
-rwxr-xr-xlua/step6_file.lua5
-rwxr-xr-xlua/step7_quote.lua5
-rwxr-xr-xlua/step8_macros.lua5
-rwxr-xr-xlua/step9_try.lua31
-rwxr-xr-xlua/stepA_mal.lua (renamed from lua/stepA_interop.lua)5
-rw-r--r--make/Makefile4
-rw-r--r--make/stepA_mal.mk (renamed from make/stepA_interop.mk)0
-rw-r--r--make/tests/stepA_mal.mal (renamed from make/tests/stepA_interop.mal)0
-rw-r--r--mal/Makefile2
-rw-r--r--mal/stepA_mal.mal (renamed from mal/stepA_interop.mal)0
-rw-r--r--matlab/Makefile2
-rw-r--r--matlab/stepA_mal.m (renamed from matlab/stepA_interop.m)2
-rw-r--r--miniMAL/Makefile2
-rw-r--r--miniMAL/stepA_mal.json (renamed from miniMAL/stepA_interop.json)0
-rw-r--r--ocaml/Makefile6
-rw-r--r--ocaml/stepA_mal.ml (renamed from ocaml/stepA_interop.ml)0
-rw-r--r--perf.mal20
-rw-r--r--perl/Makefile2
-rw-r--r--perl/stepA_mal.pl (renamed from perl/stepA_interop.pl)0
-rw-r--r--perl/tests/stepA_mal.mal (renamed from perl/tests/stepA_interop.mal)0
-rw-r--r--php/Makefile2
-rw-r--r--php/stepA_mal.php (renamed from php/stepA_interop.php)14
-rw-r--r--php/tests/stepA_mal.mal (renamed from php/tests/stepA_interop.mal)0
-rw-r--r--process/guide.md16
-rw-r--r--process/stepA_mal.gliffy (renamed from process/stepA_interop.gliffy)0
-rw-r--r--process/stepA_mal.png (renamed from process/stepA_interop.png)bin83168 -> 83168 bytes
-rw-r--r--process/stepA_mal.txt (renamed from process/stepA_interop.txt)2
-rw-r--r--ps/Makefile2
-rw-r--r--ps/interop.ps4
-rw-r--r--ps/stepA_mal.ps (renamed from ps/stepA_interop.ps)0
-rw-r--r--ps/tests/stepA_mal.mal23
-rw-r--r--python/Makefile2
-rw-r--r--python/stepA_mal.py (renamed from python/stepA_interop.py)0
-rw-r--r--r/Makefile2
-rw-r--r--r/stepA_mal.r (renamed from r/stepA_interop.r)0
-rw-r--r--racket/Makefile2
-rwxr-xr-xracket/stepA_mal.rkt (renamed from racket/stepA_interop.rkt)0
-rw-r--r--ruby/Makefile2
-rw-r--r--ruby/core.rb4
-rw-r--r--ruby/mal_readline.rb2
-rw-r--r--ruby/printer.rb2
-rw-r--r--ruby/reader.rb2
-rw-r--r--ruby/step0_repl.rb3
-rw-r--r--ruby/step1_read_print.rb9
-rw-r--r--ruby/step2_eval.rb9
-rw-r--r--ruby/step3_env.rb11
-rw-r--r--ruby/step4_if_fn_do.rb13
-rw-r--r--ruby/step5_tco.rb13
-rw-r--r--ruby/step6_file.rb13
-rw-r--r--ruby/step7_quote.rb13
-rw-r--r--ruby/step8_macros.rb13
-rw-r--r--ruby/step9_try.rb13
-rw-r--r--ruby/stepA_mal.rb (renamed from ruby/stepA_interop.rb)19
-rw-r--r--ruby/tests/stepA_mal.mal (renamed from ruby/tests/stepA_interop.mal)0
-rw-r--r--ruby/types.rb2
-rwxr-xr-xruntest-old.py134
-rwxr-xr-xruntest.py95
-rw-r--r--rust/Cargo.toml2
-rw-r--r--rust/Makefile11
-rw-r--r--rust/src/stepA_mal.rs (renamed from rust/src/stepA_interop.rs)0
-rw-r--r--scala/Makefile2
-rw-r--r--scala/stepA_mal.scala (renamed from scala/stepA_interop.scala)2
-rw-r--r--tests/perf3.mal28
-rw-r--r--tests/step2_eval.mal4
-rw-r--r--vb/Makefile4
-rw-r--r--vb/stepA_mal.vb (renamed from vb/stepA_interop.vb)2
107 files changed, 527 insertions, 190 deletions
diff --git a/.gitignore b/.gitignore
index 07d7921..2b05376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,7 @@ c/*.o
*/step7_quote
*/step8_macros
*/step9_try
-*/stepA_interop
+*/stepA_mal
cs/*.exe
cs/*.dll
cs/*.mdb
diff --git a/Makefile b/Makefile
index 47c7829..85652a6 100644
--- a/Makefile
+++ b/Makefile
@@ -24,23 +24,26 @@ step6 = step6_file
step7 = step7_quote
step8 = step8_macros
step9 = step9_try
-stepA = stepA_interop
+stepA = stepA_mal
EXCLUDE_TESTS += test^bash^step5 # no stack exhaustion or completion
EXCLUDE_TESTS += test^c^step5 # segfault
EXCLUDE_TESTS += test^cs^step5 # fatal stack overflow fault
+EXCLUDE_TESTS += test^haskell^step5 # test completes
EXCLUDE_TESTS += test^make^step5 # no TCO capability/step
EXCLUDE_TESTS += test^mal^step5 # no TCO capability/step
EXCLUDE_TESTS += test^go^step5 # test completes, even at 100,000
EXCLUDE_TESTS += test^php^step5 # test completes, even at 100,000
+EXCLUDE_TESTS += test^racket^step5 # test completes
EXCLUDE_TESTS += test^ruby^step5 # test completes, even at 100,000
EXCLUDE_TESTS += test^rust^step5 # no catching stack overflows
EXCLUDE_TESTS += test^ocaml^step5 # test completes, even at 1,000,000
# interop tests now implemented yet
-EXCLUDE_TESTS += test^cs^stepA test^java^stepA test^mal^stepA \
- test^mal^step0 test^php^stepA test^ps^stepA \
- test^python^stepA test^ruby^stepA
+EXCLUDE_TESTS += test^cs^stepA test^go^stepA test^haskell^stepA \
+ test^java^stepA test^mal^stepA test^mal^step0 \
+ test^php^stepA test^ps^stepA test^python^stepA \
+ test^ruby^stepA
EXCLUDE_PERFS = perf^mal # TODO: fix this
@@ -92,7 +95,7 @@ go_RUNSTEP = ../$(2) $(3)
haskell_RUNSTEP = ../$(2) $(3)
java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" -Dexec.args="--raw$(if $(3), $(3),)"
js_RUNSTEP = node ../$(2) $(3)
-lua_RUNSTEP = ../$(2) $(3)
+lua_RUNSTEP = ../$(2) --raw $(3)
make_RUNSTEP = make -f ../$(2) $(3)
mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #"
ocaml_RUNSTEP = ../$(2) $(3)
@@ -112,7 +115,7 @@ vb_RUNSTEP = mono ../$(2) --raw $(3)
# Extra options to pass to runtest.py
cs_TEST_OPTS = --redirect
-mal_TEST_OPTS = --redirect --start-timeout 60 --test-timeout 120
+mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
vb_TEST_OPTS = --redirect
@@ -193,5 +196,7 @@ $(IMPL_PERF):
echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \
$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \
echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \
- $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal))
+ $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal); \
+ echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)'; \
+ $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal))
diff --git a/README.md b/README.md
index 612743c..1885174 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
## Description
-Mal is an Clojure inspired Lisp interpreter.
+Mal is a Clojure inspired Lisp interpreter.
Mal is implemented in 26 different languages:
@@ -51,7 +51,7 @@ The mal (make a lisp) steps are:
* [step7_quote](process/guide.md#step7)
* [step8_macros](process/guide.md#step8)
* [step9_try](process/guide.md#step9)
-* [stepA_interop](process/guide.md#stepA)
+* [stepA_mal](process/guide.md#stepA)
Mal was presented publicly for the first time in a lightning talk at
@@ -286,7 +286,7 @@ cd racket
./stepX_YYY.rb
```
-### Ruby (1.8)
+### Ruby (1.9+)
```
cd ruby
diff --git a/bash/Makefile b/bash/Makefile
index 5028788..dc1d1ad 100644
--- a/bash/Makefile
+++ b/bash/Makefile
@@ -1,5 +1,5 @@
SOURCES_BASE = types.sh reader.sh printer.sh
-SOURCES_LISP = env.sh core.sh stepA_interop.sh
+SOURCES_LISP = env.sh core.sh stepA_mal.sh
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all: mal.sh
diff --git a/bash/stepA_interop.sh b/bash/stepA_mal.sh
index 7b43496..7b43496 100755
--- a/bash/stepA_interop.sh
+++ b/bash/stepA_mal.sh
diff --git a/bash/tests/stepA_interop.mal b/bash/tests/stepA_mal.mal
index bf3eabd..bf3eabd 100644
--- a/bash/tests/stepA_interop.mal
+++ b/bash/tests/stepA_mal.mal
diff --git a/c/Makefile b/c/Makefile
index 81b384c..e51e04b 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -9,7 +9,7 @@ TESTS =
SOURCES_BASE = readline.h readline.c types.h types.c \
reader.h reader.c printer.h printer.c \
interop.h interop.c
-SOURCES_LISP = env.c core.h core.c stepA_interop.c
+SOURCES_LISP = env.c core.h core.c stepA_mal.c
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
@@ -17,7 +17,7 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
SRCS = step0_repl.c step1_read_print.c step2_eval.c step3_env.c \
step4_if_fn_do.c step5_tco.c step6_file.c step7_quote.c \
- step8_macros.c step9_try.c stepA_interop.c
+ step8_macros.c step9_try.c stepA_mal.c
OBJS = $(SRCS:%.c=%.o)
BINS = $(OBJS:%.o=%)
OTHER_OBJS = types.o readline.o reader.o printer.o env.o core.o interop.o
diff --git a/c/stepA_interop.c b/c/stepA_mal.c
index 05e9f65..05e9f65 100644
--- a/c/stepA_interop.c
+++ b/c/stepA_mal.c
diff --git a/c/tests/stepA_interop.mal b/c/tests/stepA_mal.mal
index 657e3e7..657e3e7 100644
--- a/c/tests/stepA_interop.mal
+++ b/c/tests/stepA_mal.mal
diff --git a/clojure/Makefile b/clojure/Makefile
index 6d227a2..ec55ac1 100644
--- a/clojure/Makefile
+++ b/clojure/Makefile
@@ -1,5 +1,5 @@
SOURCES_BASE = src/readline.clj src/reader.clj src/printer.clj
-SOURCES_LISP = src/env.clj src/core.clj src/stepA_interop.clj
+SOURCES_LISP = src/env.clj src/core.clj src/stepA_mal.clj
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all:
diff --git a/clojure/src/stepA_interop.clj b/clojure/src/stepA_mal.clj
index 6ed9964..6ed9964 100644
--- a/clojure/src/stepA_interop.clj
+++ b/clojure/src/stepA_mal.clj
diff --git a/clojure/tests/stepA_interop.mal b/clojure/tests/stepA_mal.mal
index b323222..b323222 100644
--- a/clojure/tests/stepA_interop.mal
+++ b/clojure/tests/stepA_mal.mal
diff --git a/coffee/Makefile b/coffee/Makefile
index d2212ed..728d9f2 100644
--- a/coffee/Makefile
+++ b/coffee/Makefile
@@ -2,7 +2,7 @@ TESTS =
SOURCES_BASE = node_readline.coffee types.coffee \
reader.coffee printer.coffee
-SOURCES_LISP = env.coffee core.coffee stepA_interop.coffee
+SOURCES_LISP = env.coffee core.coffee stepA_mal.coffee
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#all: mal.rb
diff --git a/coffee/stepA_interop.coffee b/coffee/stepA_mal.coffee
index 751f9ad..751f9ad 100644
--- a/coffee/stepA_interop.coffee
+++ b/coffee/stepA_mal.coffee
diff --git a/coffee/tests/stepA_interop.mal b/coffee/tests/stepA_mal.mal
index f785292..f785292 100644
--- a/coffee/tests/stepA_interop.mal
+++ b/coffee/tests/stepA_mal.mal
diff --git a/cs/Makefile b/cs/Makefile
index 1fd1f7a..70d54ad 100644
--- a/cs/Makefile
+++ b/cs/Makefile
@@ -5,7 +5,7 @@ DEBUG =
TESTS =
SOURCES_BASE = readline.cs types.cs reader.cs printer.cs
-SOURCES_LISP = env.cs core.cs stepA_interop.cs
+SOURCES_LISP = env.cs core.cs stepA_mal.cs
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
OTHER_SOURCES = getline.cs
@@ -14,7 +14,7 @@ OTHER_SOURCES = getline.cs
SRCS = step0_repl.cs step1_read_print.cs step2_eval.cs step3_env.cs \
step4_if_fn_do.cs step5_tco.cs step6_file.cs step7_quote.cs \
- step8_macros.cs step9_try.cs stepA_interop.cs
+ step8_macros.cs step9_try.cs stepA_mal.cs
LIB_SRCS = $(filter-out step%,$(OTHER_SOURCES) $(SOURCES))
diff --git a/cs/stepA_interop.cs b/cs/stepA_mal.cs
index 2e8fc12..0ccb39e 100644
--- a/cs/stepA_interop.cs
+++ b/cs/stepA_mal.cs
@@ -14,7 +14,7 @@ using MalFunc = Mal.types.MalFunc;
using Env = Mal.env.Env;
namespace Mal {
- class stepA_interop {
+ class stepA_mal {
// read
static MalVal READ(string str) {
return reader.read_str(str);
@@ -231,10 +231,10 @@ namespace Mal {
}
repl_env.set(new MalSymbol("eval"), new MalFunc(
a => EVAL(a[0], repl_env)));
- int fileIdx = 1;
+ int fileIdx = 0;
if (args.Length > 0 && args[0] == "--raw") {
Mal.readline.mode = Mal.readline.Mode.Raw;
- fileIdx = 2;
+ fileIdx = 1;
}
MalList _argv = new MalList();
for (int i=fileIdx; i < args.Length; i++) {
diff --git a/docs/TODO b/docs/TODO
index 741d024..e586f52 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -1,5 +1,6 @@
All:
- - rename stepA_interop to stepA_mal
+ - Finish guide.md
+
- test to check args set properly
- test to make sure slurp captures final newline
- make sure errors propagate/print properly when self-hosted
@@ -8,8 +9,9 @@ All:
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
+ * stop using expect, so we can drop --raw option
+ - fix C#, VB
+ - fix long line splitting in runtest
- regular expression matching in runtest
- add re (use in rep) everywhere and use that (to avoid printing)
- Implement/fix interop
@@ -57,6 +59,8 @@ C:
C#:
- fix command line arg processing (doesn't run file specified)
- accumulates line breaks with mal/clojurewest2014.mal
+ - step9_interop:
+ http://www.ckode.dk/programming/eval-in-c-yes-its-possible/
Clojure:
- make indent consistent across steps (e.g. step5, step8)
@@ -90,7 +94,7 @@ Lua:
Make:
- allow '_' in make variable names
- hash-map with space in key string
- - Fix: make -f stepA_interop.mk ../mal/step6_file.mal
+ - Fix: make -f stepA_mal.mk ../mal/step6_file.mal
(slurp "../tests/incA.mal")
(read-string "(+ 2 3)")
- errors should propagate up from within load-file
@@ -117,7 +121,7 @@ Postscript:
- formatting messed up with mal/clojurewest2014.mal
Python:
- - error: python ../python/stepA_interop.py ../mal/stepA_interop.mal ../mal/stepA_interop.mal
+ - error: python ../python/stepA_mal.py ../mal/stepA_mal.mal ../mal/stepA_mal.mal
- interop tests
R:
@@ -167,6 +171,10 @@ Future Implementations:
- http://api.haxe.org/
- http://haxe.us/haxe_tutorial.html
+ - Julia
+
+ - Nim
+
- Objective-C:
- Pascal:
diff --git a/docs/step_notes.txt b/docs/step_notes.txt
index f36575d..e28761a 100644
--- a/docs/step_notes.txt
+++ b/docs/step_notes.txt
@@ -405,7 +405,7 @@ Step Notes:
- Other misc:
- conj function
-- stepA_interop
+- stepA_mal
- convert returned data to mal data
- recursive, similar to pr_str
- Details:
diff --git a/forth/Makefile b/forth/Makefile
index 400b463..29bf799 100644
--- a/forth/Makefile
+++ b/forth/Makefile
@@ -1,5 +1,5 @@
SOURCES_BASE = types.fs str.fs reader.fs printer.fs
-SOURCES_LISP = env.fs core.fs stepA_interop.fs
+SOURCES_LISP = env.fs core.fs stepA_mal.fs
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
.PHONY: stats tests $(TESTS)
diff --git a/forth/stepA_interop.fs b/forth/stepA_mal.fs
index af5f5d8..af5f5d8 100644
--- a/forth/stepA_interop.fs
+++ b/forth/stepA_mal.fs
diff --git a/forth/tests/stepA_interop.mal b/forth/tests/stepA_mal.mal
index c4a0e75..c4a0e75 100644
--- a/forth/tests/stepA_interop.mal
+++ b/forth/tests/stepA_mal.mal
diff --git a/go/Makefile b/go/Makefile
index 5c966f5..67e967b 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -6,14 +6,14 @@ SOURCES_BASE = src/types/types.go src/readline/readline.go \
src/reader/reader.go src/printer/printer.go \
src/env/env.go src/core/core.go
SOURCES_LISP = src/env/env.go src/core/core.go \
- src/stepA_interop/stepA_interop.go
+ src/stepA_mal/stepA_mal.go
SOURCES = $(SOURCES_BASE) $(word $(words $(SOURCES_LISP)),${SOURCES_LISP})
#####################
SRCS = step0_repl.go step1_read_print.go step2_eval.go step3_env.go \
step4_if_fn_do.go step5_tco.go step6_file.go step7_quote.go \
- step8_macros.go step9_try.go stepA_interop.go
+ step8_macros.go step9_try.go stepA_mal.go
BINS = $(SRCS:%.go=%)
#####################
diff --git a/go/src/stepA_interop/stepA_interop.go b/go/src/stepA_mal/stepA_mal.go
index 548d72b..548d72b 100644
--- a/go/src/stepA_interop/stepA_interop.go
+++ b/go/src/stepA_mal/stepA_mal.go
diff --git a/haskell/Makefile b/haskell/Makefile
index 28c3d26..0ac1a75 100644
--- a/haskell/Makefile
+++ b/haskell/Makefile
@@ -6,7 +6,7 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
SRCS = step0_repl.hs step1_read_print.hs step2_eval.hs step3_env.hs \
step4_if_fn_do.hs step5_tco.hs step6_file.hs step7_quote.hs \
- step8_macros.hs step9_try.hs stepA_interop.hs
+ step8_macros.hs step9_try.hs stepA_mal.hs
OTHER_SRCS = Readline.hs Types.hs Reader.hs Printer.hs Env.hs Core.hs
BINS = $(SRCS:%.hs=%)
diff --git a/haskell/stepA_interop.hs b/haskell/stepA_mal.hs
index f1d4b38..f1d4b38 100644
--- a/haskell/stepA_interop.hs
+++ b/haskell/stepA_mal.hs
diff --git a/java/Makefile b/java/Makefile
index eff6e6f..f242ec0 100644
--- a/java/Makefile
+++ b/java/Makefile
@@ -5,7 +5,7 @@ TESTS =
SOURCES_BASE = src/main/java/mal/readline.java src/main/java/mal/types.java \
src/main/java/mal/reader.java src/main/java/mal/printer.java
SOURCES_LISP = src/main/java/mal/env.java src/main/java/mal/core.java \
- src/main/java/mal/stepA_interop.java
+ src/main/java/mal/stepA_mal.java
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#.PHONY: stats tests $(TESTS)
diff --git a/java/pom.xml b/java/pom.xml
index ae53194..fa2b567 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -47,7 +47,7 @@
</executions>
<configuration>
<!--
- <mainClass>mal.stepA_interop</mainClass>
+ <mainClass>mal.stepA_mal</mainClass>
<arguments>
<argument>foo</argument>
<argument>bar</argument>
@@ -69,7 +69,7 @@
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>mal.stepA_interop</mainClass>
+ <mainClass>mal.stepA_mal</mainClass>
</transformer>
</transformers>
</configuration>
diff --git a/java/src/main/java/mal/stepA_interop.java b/java/src/main/java/mal/stepA_mal.java
index 1fa1125..f8d4056 100644
--- a/java/src/main/java/mal/stepA_interop.java
+++ b/java/src/main/java/mal/stepA_mal.java
@@ -15,7 +15,7 @@ import mal.printer;
import mal.env.Env;
import mal.core;
-public class stepA_interop {
+public class stepA_mal {
// read
public static MalVal READ(String str) throws MalThrowable {
return reader.read_str(str);
diff --git a/js/Makefile b/js/Makefile
index 09ed5a4..98c4291 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -2,7 +2,7 @@
TESTS = tests/types.js tests/reader.js
SOURCES_BASE = node_readline.js types.js reader.js printer.js
-SOURCES_LISP = env.js core.js stepA_interop.js
+SOURCES_LISP = env.js core.js stepA_mal.js
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
WEB_SOURCES = $(SOURCES:node_readline.js=jq_readline.js)
diff --git a/js/stepA_interop.js b/js/stepA_mal.js
index 456c006..d879cd3 100644
--- a/js/stepA_interop.js
+++ b/js/stepA_mal.js
@@ -5,6 +5,7 @@ if (typeof module !== 'undefined') {
var printer = require('./printer');
var Env = require('./env').Env;
var core = require('./core');
+ var interop = require('./interop');
}
// read
@@ -108,8 +109,11 @@ function _EVAL(ast, env) {
return eval(a1.toString());
case ".":
var el = eval_ast(ast.slice(2), env),
- f = eval(a1.toString());
- return f.apply(f, el);
+ r = interop.resolve_js(a1.toString()),
+ obj = r[0], f = r[1];
+ var res = f.apply(obj, el);
+ console.log("DEBUG3:", res);
+ return interop.js_to_mal(res);
case "try*":
try {
return EVAL(a1, env);
diff --git a/js/tests/stepA_interop.mal b/js/tests/stepA_mal.mal
index f785292..f785292 100644
--- a/js/tests/stepA_interop.mal
+++ b/js/tests/stepA_mal.mal
diff --git a/js/types.js b/js/types.js
index 848a484..e3901b7 100644
--- a/js/types.js
+++ b/js/types.js
@@ -79,6 +79,10 @@ function _clone (obj) {
default:
throw new Error("clone of non-collection: " + _obj_type(obj));
}
+ Object.defineProperty(new_obj, "__meta__", {
+ enumerable: false,
+ writable: true
+ });
return new_obj;
}
diff --git a/lua/Makefile b/lua/Makefile
index d1498bd..169c587 100644
--- a/lua/Makefile
+++ b/lua/Makefile
@@ -1,7 +1,7 @@
TESTS =
SOURCES_BASE = utils.lua types.lua reader.lua printer.lua
-SOURCES_LISP = env.lua core.lua stepA_interop.lua
+SOURCES_LISP = env.lua core.lua stepA_mal.lua
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all: libs
diff --git a/lua/core.lua b/lua/core.lua
index 3f46aeb..279a6d6 100644
--- a/lua/core.lua
+++ b/lua/core.lua
@@ -23,12 +23,14 @@ end
function prn(...)
print(table.concat(
utils.map(function(e) return _pr_str(e, true) end, arg), " "))
+ io.flush()
return Nil
end
function println(...)
print(table.concat(
utils.map(function(e) return _pr_str(e, false) end, arg), " "))
+ io.flush()
return Nil
end
diff --git a/lua/readline.lua b/lua/readline.lua
index a75f4ff..5acdb54 100644
--- a/lua/readline.lua
+++ b/lua/readline.lua
@@ -5,6 +5,8 @@ local M = {}
local history_loaded = false
local history_file = os.getenv("HOME") .. "/.mal-history"
+M.raw = false
+
function M.readline(prompt)
if not history_loaded then
history_loaded = true
@@ -13,7 +15,12 @@ function M.readline(prompt)
end
end
- line = LN.linenoise(prompt)
+ if M.raw then
+ io.write(prompt); io.flush();
+ line = io.read()
+ else
+ line = LN.linenoise(prompt)
+ end
if line then
LN.historyadd(line)
local f = io.open(history_file, "a")
diff --git a/lua/step1_read_print.lua b/lua/step1_read_print.lua
index abd555d..46d71f5 100755
--- a/lua/step1_read_print.lua
+++ b/lua/step1_read_print.lua
@@ -25,6 +25,10 @@ function rep(str)
return PRINT(EVAL(READ(str),""))
end
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+end
+
while true do
line = readline.readline("user> ")
if not line then break end
diff --git a/lua/step2_eval.lua b/lua/step2_eval.lua
index 7487064..22ac8cf 100755
--- a/lua/step2_eval.lua
+++ b/lua/step2_eval.lua
@@ -58,6 +58,10 @@ function rep(str)
return PRINT(EVAL(READ(str),repl_env))
end
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+end
+
while true do
line = readline.readline("user> ")
if not line then break end
diff --git a/lua/step3_env.lua b/lua/step3_env.lua
index ed2e62a..dbdb879 100755
--- a/lua/step3_env.lua
+++ b/lua/step3_env.lua
@@ -71,6 +71,10 @@ repl_env:set(types.Symbol:new('-'), function(a,b) return a-b end)
repl_env:set(types.Symbol:new('*'), function(a,b) return a*b end)
repl_env:set(types.Symbol:new('/'), function(a,b) return math.floor(a/b) end)
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+end
+
while true do
line = readline.readline("user> ")
if not line then break end
diff --git a/lua/step4_if_fn_do.lua b/lua/step4_if_fn_do.lua
index e211973..65b3a0a 100755
--- a/lua/step4_if_fn_do.lua
+++ b/lua/step4_if_fn_do.lua
@@ -89,6 +89,10 @@ end
-- core.mal: defined using mal
rep("(def! not (fn* (a) (if a false true)))")
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+end
+
while true do
line = readline.readline("user> ")
if not line then break end
diff --git a/lua/step5_tco.lua b/lua/step5_tco.lua
index fa4e41f..237f5ea 100755
--- a/lua/step5_tco.lua
+++ b/lua/step5_tco.lua
@@ -97,6 +97,10 @@ end
-- core.mal: defined using mal
rep("(def! not (fn* (a) (if a false true)))")
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+end
+
while true do
line = readline.readline("user> ")
if not line then break end
diff --git a/lua/step6_file.lua b/lua/step6_file.lua
index b109a90..7992888 100755
--- a/lua/step6_file.lua
+++ b/lua/step6_file.lua
@@ -101,6 +101,11 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2)))
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+ table.remove(arg,1)
+end
+
if #arg > 0 then
rep("(load-file \""..arg[1].."\")")
os.exit(0)
diff --git a/lua/step7_quote.lua b/lua/step7_quote.lua
index 974e342..32bf60c 100755
--- a/lua/step7_quote.lua
+++ b/lua/step7_quote.lua
@@ -127,6 +127,11 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2)))
rep("(def! not (fn* (a) (if a false true)))")
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+ table.remove(arg,1)
+end
+
if #arg > 0 then
rep("(load-file \""..arg[1].."\")")
os.exit(0)
diff --git a/lua/step8_macros.lua b/lua/step8_macros.lua
index 46a5881..25a9238 100755
--- a/lua/step8_macros.lua
+++ b/lua/step8_macros.lua
@@ -156,6 +156,11 @@ 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)))))))")
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+ table.remove(arg,1)
+end
+
if #arg > 0 then
rep("(load-file \""..arg[1].."\")")
os.exit(0)
diff --git a/lua/step9_try.lua b/lua/step9_try.lua
index f3d8cce..315d698 100755
--- a/lua/step9_try.lua
+++ b/lua/step9_try.lua
@@ -174,23 +174,30 @@ 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)))))))")
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
+function print_exception(exc)
+ if exc then
+ if types._malexception_Q(exc) then
+ exc = printer._pr_str(exc.val, true)
+ end
+ print("Error: " .. exc)
+ print(debug.traceback())
+ end
+end
+
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+ table.remove(arg,1)
+end
+
if #arg > 0 then
- rep("(load-file \""..arg[1].."\")")
+ xpcall(function() rep("(load-file \""..arg[1].."\")") end,
+ print_exception)
os.exit(0)
end
while true do
line = readline.readline("user> ")
if not line then break end
- xpcall(function()
- print(rep(line))
- end, function(exc)
- if exc then
- if types._malexception_Q(exc) then
- exc = printer._pr_str(exc.val, true)
- end
- print("Error: " .. exc)
- print(debug.traceback())
- end
- end)
+ xpcall(function() print(rep(line)) end,
+ print_exception)
end
diff --git a/lua/stepA_interop.lua b/lua/stepA_mal.lua
index 430fffc..db31789 100755
--- a/lua/stepA_interop.lua
+++ b/lua/stepA_mal.lua
@@ -185,6 +185,11 @@ function print_exception(exc)
end
end
+if #arg > 0 and arg[1] == "--raw" then
+ readline.raw = true
+ table.remove(arg,1)
+end
+
if #arg > 0 then
xpcall(function() rep("(load-file \""..arg[1].."\")") end,
print_exception)
diff --git a/make/Makefile b/make/Makefile
index 39658ac..70dea08 100644
--- a/make/Makefile
+++ b/make/Makefile
@@ -1,9 +1,9 @@
-TESTS = tests/types.mk tests/reader.mk tests/stepA_interop.mk
+TESTS = tests/types.mk tests/reader.mk tests/stepA_mal.mk
SOURCES_BASE = util.mk numbers.mk readline.mk gmsl.mk types.mk \
reader.mk printer.mk
-SOURCES_LISP = env.mk core.mk stepA_interop.mk
+SOURCES_LISP = env.mk core.mk stepA_mal.mk
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
mal.mk: $(SOURCES)
diff --git a/make/stepA_interop.mk b/make/stepA_mal.mk
index 80909c7..80909c7 100644
--- a/make/stepA_interop.mk
+++ b/make/stepA_mal.mk
diff --git a/make/tests/stepA_interop.mal b/make/tests/stepA_mal.mal
index 9b1a2f9..9b1a2f9 100644
--- a/make/tests/stepA_interop.mal
+++ b/make/tests/stepA_mal.mal
diff --git a/mal/Makefile b/mal/Makefile
index 1990b6b..0848621 100644
--- a/mal/Makefile
+++ b/mal/Makefile
@@ -2,7 +2,7 @@
TESTS =
SOURCES_BASE =
-SOURCES_LISP = env.mal core.mal stepA_interop.mal
+SOURCES_LISP = env.mal core.mal stepA_mal.mal
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#.PHONY: stats tests $(TESTS)
diff --git a/mal/stepA_interop.mal b/mal/stepA_mal.mal
index 3e2a258..3e2a258 100644
--- a/mal/stepA_interop.mal
+++ b/mal/stepA_mal.mal
diff --git a/matlab/Makefile b/matlab/Makefile
index a603822..f03d94d 100644
--- a/matlab/Makefile
+++ b/matlab/Makefile
@@ -2,7 +2,7 @@ SOURCES_BASE = types.m types/Nil.m types/MalException.m \
types/Symbol.m types/List.m types/Vector.m \
types/HashMap.m types/Function.m types/Atom.m \
Reader.m reader.m printer.m
-SOURCES_LISP = Env.m core.m stepA_interop.m
+SOURCES_LISP = Env.m core.m stepA_mal.m
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
diff --git a/matlab/stepA_interop.m b/matlab/stepA_mal.m
index 5b8e720..6f74b6a 100644
--- a/matlab/stepA_interop.m
+++ b/matlab/stepA_mal.m
@@ -1,4 +1,4 @@
-function stepA_interop(varargin), main(varargin), end
+function stepA_mal(varargin), main(varargin), end
% read
function ret = READ(str)
diff --git a/miniMAL/Makefile b/miniMAL/Makefile
index 9e31c40..8c838d3 100644
--- a/miniMAL/Makefile
+++ b/miniMAL/Makefile
@@ -1,7 +1,7 @@
SOURCES_BASE = node_readline.js miniMAL-core.json \
types.json reader.json printer.json
-SOURCES_LISP = env.json core.json stepA_interop.json
+SOURCES_LISP = env.json core.json stepA_mal.json
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
.PHONY: stats tests $(TESTS)
diff --git a/miniMAL/stepA_interop.json b/miniMAL/stepA_mal.json
index 2181d30..2181d30 100644
--- a/miniMAL/stepA_interop.json
+++ b/miniMAL/stepA_mal.json
diff --git a/ocaml/Makefile b/ocaml/Makefile
index 71c7e6b..9245dd5 100644
--- a/ocaml/Makefile
+++ b/ocaml/Makefile
@@ -1,6 +1,6 @@
STEPS = step0_repl.ml step1_read_print.ml step2_eval.ml step3_env.ml \
step4_if_fn_do.ml step5_tco.ml step6_file.ml step7_quote.ml \
- step8_macros.ml step9_try.ml stepA_interop.ml
+ step8_macros.ml step9_try.ml stepA_mal.ml
MODULES = types.ml reader.ml printer.ml env.ml core.ml
LIBS = str.cmxa unix.cmxa
MAL_LIB = mal_lib.cmxa
@@ -28,10 +28,10 @@ $(STEP_BINS): %: %.ml $(MAL_LIB)
clean:
rm -f $(STEP_BINS) mal mal_lib.* *.cmo *.cmx *.cmi *.o
-stats: $(MODULES) stepA_interop.ml
+stats: $(MODULES) stepA_mal.ml
@wc $^
-stats-lisp: env.ml core.ml stepA_interop.ml
+stats-lisp: env.ml core.ml stepA_mal.ml
@wc $^
.PHONY: all repl clean stats stats-lisp
diff --git a/ocaml/stepA_interop.ml b/ocaml/stepA_mal.ml
index 1aab28a..1aab28a 100644
--- a/ocaml/stepA_interop.ml
+++ b/ocaml/stepA_mal.ml
diff --git a/perf.mal b/perf.mal
index 94da2ff..83bbc0d 100644
--- a/perf.mal
+++ b/perf.mal
@@ -5,3 +5,23 @@
(do
(prn (str "Elapsed time: " (- (time-ms) start_FIXME) " msecs"))
ret_FIXME))))
+
+(def! run-fn-for*
+ (fn* [fn max-ms acc-ms iters]
+ (let* [start (time-ms)
+ _ (fn)
+ elapsed (- (time-ms) start)
+ new-iters (+ 1 iters)
+ new-acc-ms (+ acc-ms elapsed)]
+ ;(do (prn "here:" new-acc-ms "/" max-ms "iters:" new-iters) )
+ (if (>= new-acc-ms max-ms)
+ (/ (* max-ms iters) new-acc-ms)
+ (run-fn-for* fn max-ms new-acc-ms new-iters)))))
+
+(def! run-fn-for
+ (fn* [fn max-secs]
+ (do
+ ;; Warm it up first
+ (run-fn-for* fn 1000 0 0)
+ ;; Now do the test
+ (/ (run-fn-for* fn (* 1000 max-secs) 0 0) 3))))
diff --git a/perl/Makefile b/perl/Makefile
index d8e95a0..0aed9c6 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -2,7 +2,7 @@ TESTS =
SOURCES_BASE = readline.pm types.pm reader.pm printer.pm \
interop.pm
-SOURCES_LISP = env.pm core.pm stepA_interop.pl
+SOURCES_LISP = env.pm core.pm stepA_mal.pl
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#all: mal.pl
diff --git a/perl/stepA_interop.pl b/perl/stepA_mal.pl
index 7993635..7993635 100644
--- a/perl/stepA_interop.pl
+++ b/perl/stepA_mal.pl
diff --git a/perl/tests/stepA_interop.mal b/perl/tests/stepA_mal.mal
index 1335be4..1335be4 100644
--- a/perl/tests/stepA_interop.mal
+++ b/perl/tests/stepA_mal.mal
diff --git a/php/Makefile b/php/Makefile
index d9fd2d4..659e89c 100644
--- a/php/Makefile
+++ b/php/Makefile
@@ -2,7 +2,7 @@
TESTS =
SOURCES_BASE = readline.php types.php reader.php printer.php
-SOURCES_LISP = env.php core.php stepA_interop.php
+SOURCES_LISP = env.php core.php stepA_mal.php
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
.PHONY: stats tests $(TESTS)
diff --git a/php/stepA_interop.php b/php/stepA_mal.php
index 8c67c66..1dc3b04 100644
--- a/php/stepA_interop.php
+++ b/php/stepA_mal.php
@@ -109,7 +109,19 @@ function MAL_EVAL($ast, $env) {
case "macroexpand":
return macroexpand($ast[1], $env);
case "php*":
- return eval($ast[1]);
+ $res = eval($ast[1]);
+ switch (gettype($res)) {
+ case "array":
+ if ($res !== array_values($res)) {
+ $new_res = _hash_map();
+ $new_res->exchangeArray($res);
+ return $new_res;
+ } else {
+ return call_user_func_array('_list', $res);
+ }
+ default:
+ return $res;
+ }
case "try*":
$a1 = $ast[1];
$a2 = $ast[2];
diff --git a/php/tests/stepA_interop.mal b/php/tests/stepA_mal.mal
index 15f8a94..15f8a94 100644
--- a/php/tests/stepA_interop.mal
+++ b/php/tests/stepA_mal.mal
diff --git a/process/guide.md b/process/guide.md
index 734dc32..6c6887c 100644
--- a/process/guide.md
+++ b/process/guide.md
@@ -15,7 +15,7 @@ So jump right in (er ... start the climb)!
You might already have a language in mind that you want to use.
Technically speaking, mal can be implemented in any sufficiently
-complete programming (i.e. Turing complete), however, there are a few
+complete programming language (i.e. Turing complete), however, there are a few
language features that can make the task MUCH easier. Here are some of
them in rough order of importance:
@@ -68,8 +68,8 @@ git clone git@github.com:YOUR_NAME/mal.git
cd mal
```
-* Make a new directory for your implementation. For example, if you
-* language is called "quux":
+* Make a new directory for your implementation. For example, if your
+language is called "quux":
```
mkdir quux
```
@@ -321,7 +321,7 @@ manually try some simple inputs:
* ` abc ` -> `abc`
* `(123 456)` -> `(123 456)`
* `( 123 456 789 ) ` -> `(123 456 789)`
- * `( + 2 (+ 3 4) ) ` -> `(+ 2 (* 3 4))`
+ * `( + 2 (* 3 4) ) ` -> `(+ 2 (* 3 4))`
To verify that your code is doing more than just eliminating extra
spaces (and not failing), you can instrument your `reader.qx` functions.
@@ -352,7 +352,7 @@ and each step will give progressively more bang for the buck.
* Add support for the other basic data type to your reader and printer
functions: string, nil, true, and false. These become mandatory at
step 4. When a string is read, a slash followed by a doublequote is
- translatd into a plain doublequote character and a slash followed by
+ translated into a plain doublequote character and a slash followed by
"n" is translated into a newline. To properly print a string (for
step 4 string functions), the `pr_str` function needs another
parameter called `print_readably`. When `print_readably` is true,
@@ -1151,15 +1151,15 @@ diff -urp ../process/step8_macros.txt ../process/step9_try.txt
### Step A: Interop and Self-hosting
-![stepA_interop architecture](stepA_interop.png)
+![stepA_mal architecture](stepA_mal.png)
Compare the pseudocode for step 9 and step A to get a basic idea of
the changes that will be made during this step:
```
-diff -urp ../process/step9_try.txt ../process/stepA_interop.txt
+diff -urp ../process/step9_try.txt ../process/stepA_mal.txt
```
-* Copy `step9_try.qx` to `stepA_interop.qx`.
+* Copy `step9_try.qx` to `stepA_mal.qx`.
* TODO/TBD
diff --git a/process/stepA_interop.gliffy b/process/stepA_mal.gliffy
index 7d4920f..7d4920f 100644
--- a/process/stepA_interop.gliffy
+++ b/process/stepA_mal.gliffy
diff --git a/process/stepA_interop.png b/process/stepA_mal.png
index 28dcb5b..28dcb5b 100644
--- a/process/stepA_interop.png
+++ b/process/stepA_mal.png
Binary files differ
diff --git a/process/stepA_interop.txt b/process/stepA_mal.txt
index 8d36f31..6c1e71e 100644
--- a/process/stepA_interop.txt
+++ b/process/stepA_mal.txt
@@ -1,4 +1,4 @@
---- stepA_interop -------------------------------
+--- stepA_mal -------------------------------
import types, reader, printer, env, core
READ(str): return reader.read_str(str)
diff --git a/ps/Makefile b/ps/Makefile
index 26056a6..9131674 100644
--- a/ps/Makefile
+++ b/ps/Makefile
@@ -2,7 +2,7 @@
TESTS =
SOURCES_BASE = types.ps reader.ps printer.ps
-SOURCES_LISP = env.ps core.ps stepA_interop.ps
+SOURCES_LISP = env.ps core.ps stepA_mal.ps
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
.PHONY: stats tests $(TESTS)
diff --git a/ps/interop.ps b/ps/interop.ps
index fb3b88d..8020ab0 100644
--- a/ps/interop.ps
+++ b/ps/interop.ps
@@ -1,6 +1,6 @@
-% ps_val -> ps2mal -> mal_val
+% [ ps_val1...] -> ps2mal -> [ mal_val1...]
/ps2mal {
- % convert a PS value to a Mal value (recursively)
+ % convert returned values to Mal types
[ exch
{ %forall returned values
dup ==
diff --git a/ps/stepA_interop.ps b/ps/stepA_mal.ps
index c879294..c879294 100644
--- a/ps/stepA_interop.ps
+++ b/ps/stepA_mal.ps
diff --git a/ps/tests/stepA_mal.mal b/ps/tests/stepA_mal.mal
new file mode 100644
index 0000000..fffa178
--- /dev/null
+++ b/ps/tests/stepA_mal.mal
@@ -0,0 +1,23 @@
+;; Testing basic ps interop
+
+(ps* "7")
+;=>(7)
+
+(ps* "(7)")
+;=>("7")
+
+(ps* "7 8 9 3 array astore")
+;=>((7 8 9))
+
+(ps* "1 1 eq")
+;=>(true)
+
+(ps* "/sym")
+;=>sym
+
+(ps* "1 1 eq { (yep) }{ (nope) } ifelse")
+;=>("yep")
+
+(ps* "1 0 eq { (yep) }{ (nope) } ifelse")
+;=>("nope")
+
diff --git a/python/Makefile b/python/Makefile
index 6e51430..7842eae 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -3,7 +3,7 @@ TESTS =
SOURCES_BASE = mal_readline.py mal_types.py reader.py printer.py
-SOURCES_LISP = env.py core.py stepA_interop.py
+SOURCES_LISP = env.py core.py stepA_mal.py
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
diff --git a/python/stepA_interop.py b/python/stepA_mal.py
index 93cdb2e..93cdb2e 100644
--- a/python/stepA_interop.py
+++ b/python/stepA_mal.py
diff --git a/r/Makefile b/r/Makefile
index 9d1a35d..4d1ec24 100644
--- a/r/Makefile
+++ b/r/Makefile
@@ -1,7 +1,7 @@
TESTS =
SOURCES_BASE = readline.r types.r reader.r printer.r
-SOURCES_LISP = env.r core.r stepA_interop.r
+SOURCES_LISP = env.r core.r stepA_mal.r
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all: libs
diff --git a/r/stepA_interop.r b/r/stepA_mal.r
index e699048..e699048 100644
--- a/r/stepA_interop.r
+++ b/r/stepA_mal.r
diff --git a/racket/Makefile b/racket/Makefile
index a472c2f..01cb12a 100644
--- a/racket/Makefile
+++ b/racket/Makefile
@@ -1,5 +1,5 @@
SOURCES_BASE = types.rkt reader.rkt printer.rkt
-SOURCES_LISP = env.rkt core.rkt stepA_interop.rkt
+SOURCES_LISP = env.rkt core.rkt stepA_mal.rkt
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all:
diff --git a/racket/stepA_interop.rkt b/racket/stepA_mal.rkt
index 9b816cb..9b816cb 100755
--- a/racket/stepA_interop.rkt
+++ b/racket/stepA_mal.rkt
diff --git a/ruby/Makefile b/ruby/Makefile
index f9792f5..2241a4e 100644
--- a/ruby/Makefile
+++ b/ruby/Makefile
@@ -1,7 +1,7 @@
TESTS =
SOURCES_BASE = mal_readline.rb types.rb reader.rb printer.rb
-SOURCES_LISP = env.rb core.rb stepA_interop.rb
+SOURCES_LISP = env.rb core.rb stepA_mal.rb
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#all: mal.rb
diff --git a/ruby/core.rb b/ruby/core.rb
index d55100c..b82bddc 100644
--- a/ruby/core.rb
+++ b/ruby/core.rb
@@ -1,6 +1,6 @@
require "readline"
-require "reader"
-require "printer"
+require_relative "reader"
+require_relative "printer"
$core_ns = {
:"=" => lambda {|a,b| a == b},
diff --git a/ruby/mal_readline.rb b/ruby/mal_readline.rb
index 63c5571..3799783 100644
--- a/ruby/mal_readline.rb
+++ b/ruby/mal_readline.rb
@@ -4,7 +4,7 @@ $history_loaded = false
$histfile = "#{ENV['HOME']}/.mal-history"
def _readline(prompt)
- if not $history_loaded
+ if !$history_loaded && File.exist?($histfile)
$history_loaded = true
File.readlines($histfile).each {|l| Readline::HISTORY.push(l.chomp)}
end
diff --git a/ruby/printer.rb b/ruby/printer.rb
index 37d338a..ef067a5 100644
--- a/ruby/printer.rb
+++ b/ruby/printer.rb
@@ -1,4 +1,4 @@
-require "types"
+require_relative "types"
def _pr_str(obj, print_readably=true)
_r = print_readably
diff --git a/ruby/reader.rb b/ruby/reader.rb
index 641e65c..badc6ec 100644
--- a/ruby/reader.rb
+++ b/ruby/reader.rb
@@ -1,4 +1,4 @@
-require "types"
+require_relative "types"
class Reader
def initialize(tokens)
diff --git a/ruby/step0_repl.rb b/ruby/step0_repl.rb
index 9c03cfa..2f9e6a9 100644
--- a/ruby/step0_repl.rb
+++ b/ruby/step0_repl.rb
@@ -1,5 +1,4 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
+require_relative "mal_readline"
# read
def READ(str)
diff --git a/ruby/step1_read_print.rb b/ruby/step1_read_print.rb
index ded992a..ef416c3 100644
--- a/ruby/step1_read_print.rb
+++ b/ruby/step1_read_print.rb
@@ -1,8 +1,7 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
# read
def READ(str)
diff --git a/ruby/step2_eval.rb b/ruby/step2_eval.rb
index 50a135d..d2b7e1a 100644
--- a/ruby/step2_eval.rb
+++ b/ruby/step2_eval.rb
@@ -1,8 +1,7 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
# read
def READ(str)
diff --git a/ruby/step3_env.rb b/ruby/step3_env.rb
index 17126c5..ec8405b 100644
--- a/ruby/step3_env.rb
+++ b/ruby/step3_env.rb
@@ -1,9 +1,8 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
# read
def READ(str)
diff --git a/ruby/step4_if_fn_do.rb b/ruby/step4_if_fn_do.rb
index a93463b..151ecf6 100644
--- a/ruby/step4_if_fn_do.rb
+++ b/ruby/step4_if_fn_do.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
diff --git a/ruby/step5_tco.rb b/ruby/step5_tco.rb
index 38bb204..80be457 100644
--- a/ruby/step5_tco.rb
+++ b/ruby/step5_tco.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
diff --git a/ruby/step6_file.rb b/ruby/step6_file.rb
index 0c99cee..4eeca86 100644
--- a/ruby/step6_file.rb
+++ b/ruby/step6_file.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
diff --git a/ruby/step7_quote.rb b/ruby/step7_quote.rb
index 48385f1..23d9499 100644
--- a/ruby/step7_quote.rb
+++ b/ruby/step7_quote.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
diff --git a/ruby/step8_macros.rb b/ruby/step8_macros.rb
index 58adaea..488db12 100644
--- a/ruby/step8_macros.rb
+++ b/ruby/step8_macros.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
diff --git a/ruby/step9_try.rb b/ruby/step9_try.rb
index 74d0f59..533853b 100644
--- a/ruby/step9_try.rb
+++ b/ruby/step9_try.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
diff --git a/ruby/stepA_interop.rb b/ruby/stepA_mal.rb
index 6123293..115fc8a 100644
--- a/ruby/stepA_interop.rb
+++ b/ruby/stepA_mal.rb
@@ -1,10 +1,9 @@
-$: << File.expand_path(File.dirname(__FILE__))
-require "mal_readline"
-require "types"
-require "reader"
-require "printer"
-require "env"
-require "core"
+require_relative "mal_readline"
+require_relative "types"
+require_relative "reader"
+require_relative "printer"
+require_relative "env"
+require_relative "core"
# read
def READ(str)
@@ -96,7 +95,11 @@ def EVAL(ast, env)
when :macroexpand
return macroexpand(a1, env)
when :"rb*"
- return eval(a1)
+ res = eval(a1)
+ return case res
+ when Array; List.new res
+ else; res
+ end
when :"try*"
begin
return EVAL(a1, env)
diff --git a/ruby/tests/stepA_interop.mal b/ruby/tests/stepA_mal.mal
index 2d7efb8..2d7efb8 100644
--- a/ruby/tests/stepA_interop.mal
+++ b/ruby/tests/stepA_mal.mal
diff --git a/ruby/types.rb b/ruby/types.rb
index 72d24d1..d64664b 100644
--- a/ruby/types.rb
+++ b/ruby/types.rb
@@ -1,4 +1,4 @@
-require "env"
+require_relative "env"
class MalException < StandardError
attr_reader :data
diff --git a/runtest-old.py b/runtest-old.py
new file mode 100755
index 0000000..aacd770
--- /dev/null
+++ b/runtest-old.py
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+
+import os, sys, re
+import argparse
+
+# http://pexpect.sourceforge.net/pexpect.html
+from pexpect import spawn, EOF, TIMEOUT
+
+# TODO: do we need to support '\n' too
+sep = "\r\n"
+rundir = None
+
+parser = argparse.ArgumentParser(
+ description="Run a test file against a Mal implementation")
+parser.add_argument('--rundir',
+ help="change to the directory before running tests")
+parser.add_argument('--start-timeout', default=10, type=int,
+ help="default timeout for initial prompt")
+parser.add_argument('--test-timeout', default=20, type=int,
+ help="default timeout for each individual test action")
+parser.add_argument('--pre-eval', default=None, type=str,
+ help="Mal code to evaluate prior to running the test")
+parser.add_argument('--redirect', action='store_true',
+ help="Run implementation in bash and redirect output to /dev/null")
+
+parser.add_argument('test_file', type=argparse.FileType('r'),
+ help="a test file formatted as with mal test data")
+parser.add_argument('mal_cmd', nargs="*",
+ help="Mal implementation command line. Use '--' to "
+ "specify a Mal command line with dashed options.")
+
+args = parser.parse_args(sys.argv[1:])
+test_data = args.test_file.read().split('\n')
+
+if args.rundir: os.chdir(args.rundir)
+
+if args.redirect:
+ # Redirect to try and force raw mode (no ASCII codes)
+ p = spawn('/bin/bash -c "' + " ".join(args.mal_cmd) + ' |tee /dev/null"')
+else:
+ p = spawn(args.mal_cmd[0], args.mal_cmd[1:])
+
+
+test_idx = 0
+def read_test(data):
+ global test_idx
+ form, output, ret = None, "", None
+ while data:
+ test_idx += 1
+ line = data.pop(0)
+ if re.match(r"^\s*$", line): # blank line
+ continue
+ elif line[0:3] == ";;;": # ignore comment
+ continue
+ elif line[0:2] == ";;": # output comment
+ print line[3:]
+ continue
+ elif line[0:2] == ";": # unexpected comment
+ print "Test data error at line %d:\n%s" % (test_idx, line)
+ return None, None, None, test_idx
+ form = line # the line is a form to send
+
+ # Now find the output and return value
+ while data:
+ line = data[0]
+ if line[0:3] == ";=>":
+ ret = line[3:].replace('\\r', '\r').replace('\\n', '\n')
+ test_idx += 1
+ data.pop(0)
+ break
+ elif line[0:2] == "; ":
+ output = output + line[2:] + sep
+ test_idx += 1
+ data.pop(0)
+ else:
+ ret = "*"
+ break
+ if ret: break
+
+ return form, output, ret, test_idx
+
+def assert_prompt(timeout):
+ # Wait for the initial prompt
+ idx = p.expect(['user> ', 'mal-user> ', EOF, TIMEOUT],
+ timeout=timeout)
+ if idx not in [0,1]:
+ print "Did not get 'user> ' or 'mal-user> ' prompt"
+ print " Got : %s" % repr(p.before)
+ sys.exit(1)
+
+
+# Wait for the initial prompt
+assert_prompt(args.start_timeout)
+
+# Send the pre-eval code if any
+if args.pre_eval:
+ sys.stdout.write("RUNNING pre-eval: %s" % args.pre_eval)
+ p.sendline(args.pre_eval)
+ assert_prompt(args.test_timeout)
+
+fail_cnt = 0
+
+while test_data:
+ form, out, ret, line_num = read_test(test_data)
+ if form == None:
+ break
+ sys.stdout.write("TEST: %s -> [%s,%s]" % (form, repr(out), repr(ret)))
+ sys.stdout.flush()
+ expected = "%s%s%s%s" % (form, sep, out, ret)
+
+ p.sendline(form)
+ try:
+ idx = p.expect(['\r\nuser> ', '\nuser> ',
+ '\r\nmal-user> ', '\nmal-user> '],
+ timeout=args.test_timeout)
+ #print "%s,%s,%s" % (idx, repr(p.before), repr(p.after))
+ if ret == "*" or p.before == expected:
+ print " -> SUCCESS"
+ else:
+ print " -> FAIL (line %d):" % line_num
+ print " Expected : %s" % repr(expected)
+ print " Got : %s" % repr(p.before)
+ fail_cnt += 1
+ except EOF:
+ print "Got EOF"
+ sys.exit(1)
+ except TIMEOUT:
+ print "Got TIMEOUT, received: %s" % repr(p.before)
+ sys.exit(1)
+
+if fail_cnt > 0:
+ print "FAILURES: %d" % fail_cnt
+ sys.exit(2)
+sys.exit(0)
diff --git a/runtest.py b/runtest.py
index aacd770..e90fc68 100755
--- a/runtest.py
+++ b/runtest.py
@@ -1,13 +1,15 @@
#!/usr/bin/env python
import os, sys, re
-import argparse
+import argparse, time
-# http://pexpect.sourceforge.net/pexpect.html
-from pexpect import spawn, EOF, TIMEOUT
+import pty
+from subprocess import Popen, STDOUT, PIPE
+from select import select
# TODO: do we need to support '\n' too
sep = "\r\n"
+#sep = "\n"
rundir = None
parser = argparse.ArgumentParser(
@@ -29,16 +31,59 @@ parser.add_argument('mal_cmd', nargs="*",
help="Mal implementation command line. Use '--' to "
"specify a Mal command line with dashed options.")
+class Runner():
+ def __init__(self, args, redirect=False):
+ print "args: %s" % repr(args)
+ if redirect:
+ print "using redirect"
+ self.p = Popen(args, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
+ self.stdin = self.p.stdin
+ self.stdout = self.p.stdout
+ else:
+ # provide tty to get 'interactive' readline to work
+ master, slave = pty.openpty()
+ self.p = Popen(args, bufsize=0, stdin=slave, stdout=slave, stderr=STDOUT)
+ self.stdin = os.fdopen(master, 'r+b', 0)
+ self.stdout = self.stdin
+
+ #print "started"
+ self.buf = ""
+ self.last_prompt = ""
+
+ def read_to_prompt(self, prompts, timeout):
+ end_time = time.time() + timeout
+ while time.time() < end_time:
+ [outs,_,_] = select([self.stdin], [], [], 1)
+ if self.stdin in outs:
+ new_data = self.stdin.read(1)
+ #print "new_data: '%s'" % new_data
+ self.buf += new_data
+ for prompt in prompts:
+ regexp = re.compile(prompt)
+ match = regexp.search(self.buf)
+ if match:
+ end = match.end()
+ buf = self.buf[0:end-len(prompt)]
+ self.buf = self.buf[end:]
+ self.last_prompt = prompt
+ return buf
+ return None
+
+ def write(self, str):
+ self.stdout.write(str)
+
+ def cleanup(self):
+ if self.p:
+ self.p.terminate()
+ self.p = None
+
+
args = parser.parse_args(sys.argv[1:])
test_data = args.test_file.read().split('\n')
if args.rundir: os.chdir(args.rundir)
-if args.redirect:
- # Redirect to try and force raw mode (no ASCII codes)
- p = spawn('/bin/bash -c "' + " ".join(args.mal_cmd) + ' |tee /dev/null"')
-else:
- p = spawn(args.mal_cmd[0], args.mal_cmd[1:])
+r = Runner(args.mal_cmd, redirect=args.redirect)
test_idx = 0
@@ -81,11 +126,14 @@ def read_test(data):
def assert_prompt(timeout):
# Wait for the initial prompt
- idx = p.expect(['user> ', 'mal-user> ', EOF, TIMEOUT],
- timeout=timeout)
- if idx not in [0,1]:
+ header = r.read_to_prompt(['user> ', 'mal-user> '], timeout=timeout)
+ if not header == None:
+ if header:
+ print "Started with:\n%s" % header
+ else:
print "Did not get 'user> ' or 'mal-user> ' prompt"
- print " Got : %s" % repr(p.before)
+ print " Got : %s" % repr(r.buf)
+ r.cleanup()
sys.exit(1)
@@ -95,7 +143,7 @@ assert_prompt(args.start_timeout)
# Send the pre-eval code if any
if args.pre_eval:
sys.stdout.write("RUNNING pre-eval: %s" % args.pre_eval)
- p.sendline(args.pre_eval)
+ p.write(args.pre_eval)
assert_prompt(args.test_timeout)
fail_cnt = 0
@@ -108,25 +156,24 @@ while test_data:
sys.stdout.flush()
expected = "%s%s%s%s" % (form, sep, out, ret)
- p.sendline(form)
+ r.write(form + "\n")
try:
- idx = p.expect(['\r\nuser> ', '\nuser> ',
- '\r\nmal-user> ', '\nmal-user> '],
- timeout=args.test_timeout)
+ res = r.read_to_prompt(['\r\nuser> ', '\nuser> ',
+ '\r\nmal-user> ', '\nmal-user> '],
+ timeout=args.test_timeout)
#print "%s,%s,%s" % (idx, repr(p.before), repr(p.after))
- if ret == "*" or p.before == expected:
+ if ret == "*" or res == expected:
print " -> SUCCESS"
else:
print " -> FAIL (line %d):" % line_num
print " Expected : %s" % repr(expected)
- print " Got : %s" % repr(p.before)
+ print " Got : %s" % repr(res)
fail_cnt += 1
- except EOF:
- print "Got EOF"
- sys.exit(1)
- except TIMEOUT:
- print "Got TIMEOUT, received: %s" % repr(p.before)
+ except:
+ print "Got Exception"
+ r.cleanup()
sys.exit(1)
+r.cleanup()
if fail_cnt > 0:
print "FAILURES: %d" % fail_cnt
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index d382d32..daf999d 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -36,4 +36,4 @@ name = "step8_macros"
[[bin]]
name = "step9_try"
[[bin]]
-name = "stepA_interop"
+name = "stepA_mal"
diff --git a/rust/Makefile b/rust/Makefile
index 537dac5..da8a6c6 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -3,24 +3,27 @@
SOURCES_BASE = src/types.rs src/readline.rs \
src/reader.rs src/printer.rs \
src/env.rs src/core.rs
-SOURCES_LISP = src/env.rs src/core.rs src/stepA_interop.rs
+SOURCES_LISP = src/env.rs src/core.rs src/stepA_mal.rs
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#####################
-SRCS = step0_repl.rs step1_read_print.rs step2_eval.rs step3_env.rs \
+SRCS = step1_read_print.rs step2_eval.rs step3_env.rs \
step4_if_fn_do.rs step5_tco.rs step6_file.rs step7_quote.rs \
- step8_macros.rs step9_try.rs stepA_interop.rs
+ step8_macros.rs step9_try.rs stepA_mal.rs
BINS = $(SRCS:%.rs=target/%)
#####################
-all: $(BINS) mal
+all: mal
mal: ${SOURCES_BASE} $(word $(words ${SOURCES_LISP}),${SOURCES_LISP})
cargo build
cp $(word $(words ${BINS}),${BINS}) $@
+#$(BINS): target/%: src/%.rs
+# cargo build $*
+
clean:
cargo clean
rm -f mal
diff --git a/rust/src/stepA_interop.rs b/rust/src/stepA_mal.rs
index 8e30867..8e30867 100644
--- a/rust/src/stepA_interop.rs
+++ b/rust/src/stepA_mal.rs
diff --git a/scala/Makefile b/scala/Makefile
index 10c2e11..29dd8aa 100644
--- a/scala/Makefile
+++ b/scala/Makefile
@@ -1,7 +1,7 @@
TESTS =
SOURCES_BASE = types.scala reader.scala printer.scala
-SOURCES_LISP = env.scala core.scala stepA_interop.scala
+SOURCES_LISP = env.scala core.scala stepA_mal.scala
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#all: mal.scala
diff --git a/scala/stepA_interop.scala b/scala/stepA_mal.scala
index 2ba6b5a..5230cb1 100644
--- a/scala/stepA_interop.scala
+++ b/scala/stepA_mal.scala
@@ -2,7 +2,7 @@ import types.{MalList, _list, _list_Q, MalVector, MalHashMap,
Func, MalFunction}
import env.Env
-object stepA_interop {
+object stepA_mal {
// read
def READ(str: String): Any = {
reader.read_str(str)
diff --git a/tests/perf3.mal b/tests/perf3.mal
new file mode 100644
index 0000000..be66239
--- /dev/null
+++ b/tests/perf3.mal
@@ -0,0 +1,28 @@
+(load-file "../core.mal")
+(load-file "../perf.mal")
+
+;;(prn "Start: basic macros/atom test")
+
+(def! atm (atom (list 0 1 2 3 4 5 6 7 8 9)))
+
+(println "iters/s:"
+ (run-fn-for
+ (fn* []
+ (do
+ (or false nil false nil false nil false nil false nil (first @atm))
+ (cond false 1 nil 2 false 3 nil 4 false 5 nil 6 "else" (first @atm))
+ (-> (deref atm) rest rest rest rest rest rest first)
+ (swap! atm (fn* [a] (concat (rest a) (list (first a)))))))
+ 10))
+
+;;(def! sumdown (fn* (N) (if (> N 0) (+ N (sumdown (- N 1))) 0)))
+;;(def! fib (fn* (N) (if (= N 0) 1 (if (= N 1) 1 (+ (fib (- N 1)) (fib (- N 2)))))))
+;;
+;;(println "iters/s:"
+;; (run-fn-for
+;; (fn* []
+;; (do
+;; (sumdown 10)
+;; (fib 12)))
+;; 3))
+;;(prn "Done: basic macros/atom test")
diff --git a/tests/step2_eval.mal b/tests/step2_eval.mal
index aaf1a7d..e975910 100644
--- a/tests/step2_eval.mal
+++ b/tests/step2_eval.mal
@@ -11,8 +11,8 @@
(/ (- (+ 5 (* 2 3)) 3) 4)
;=>2
-(/ (- (+ 515 (* 222 311)) 300) 41)
-;=>1689
+(/ (- (+ 515 (* 222 311)) 302) 27)
+;=>2565
(abc 1 2 3)
; .*\'abc\' not found.*
diff --git a/vb/Makefile b/vb/Makefile
index d9ce097..25d9b96 100644
--- a/vb/Makefile
+++ b/vb/Makefile
@@ -5,14 +5,14 @@ DEBUG =
TESTS =
SOURCES_BASE = readline.vb types.vb reader.vb printer.vb
-SOURCES_LISP = env.vb core.vb stepA_interop.vb
+SOURCES_LISP = env.vb core.vb stepA_mal.vb
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
#####################
SRCS = step0_repl.vb step1_read_print.vb step2_eval.vb \
step3_env.vb step4_if_fn_do.vb step5_tco.vb step6_file.vb \
- step7_quote.vb step8_macros.vb step9_try.vb stepA_interop.vb
+ step7_quote.vb step8_macros.vb step9_try.vb stepA_mal.vb
LIB_CS_SRCS = getline.cs
LIB_VB_SRCS = $(filter-out step%,$(filter %.vb,$(SOURCES)))
diff --git a/vb/stepA_interop.vb b/vb/stepA_mal.vb
index f9af038..6778e0a 100644
--- a/vb/stepA_interop.vb
+++ b/vb/stepA_mal.vb
@@ -13,7 +13,7 @@ Imports MalFunc = Mal.types.MalFunc
Imports MalEnv = Mal.env.Env
Namespace Mal
- Class stepA_interop
+ Class stepA_mal
' read
Shared Function READ(str As String) As MalVal
Return reader.read_str(str)