From 8adb082743f12402d0817018ab1e8ff0c0e4729e Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sun, 13 Apr 2014 15:36:02 -0500 Subject: Java, JS: cleanup and sync steps. - Java: less direct use of obj.value attribute. --- README.md | 10 +++++- docs/TODO | 21 ++++++----- java/src/main/java/mal/core.java | 60 +++++++++++++++----------------- java/src/main/java/mal/step5_tco.java | 2 +- java/src/main/java/mal/step6_file.java | 6 +++- java/src/main/java/mal/step7_quote.java | 6 +++- java/src/main/java/mal/step8_macros.java | 8 +++-- java/src/main/java/mal/stepA_more.java | 2 +- java/src/main/java/mal/types.java | 3 ++ js/step5_tco.js | 2 +- js/step6_file.js | 2 +- js/step7_quote.js | 10 ++++-- js/step8_macros.js | 10 ++++-- js/step9_interop.js | 10 ++++-- js/stepA_more.js | 10 ++++-- 15 files changed, 102 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 2653b90..4b34c12 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Description Mal is an interpreter for a subset of the Clojure programming -language. Mal is implemetated from scratch in 11 different languages: +language. Mal is implemetated from scratch in 12 different languages: * Bash shell * C @@ -16,6 +16,7 @@ language. Mal is implemetated from scratch in 11 different languages: * PHP * Postscript * Python +* Ruby Mal is also a learning tool. Each implentation of mal is separated @@ -140,3 +141,10 @@ gs -q -dNODISPLAY stepX_YYY.ps cd python python stepX_YYY.py ``` + +### Ruby (1.8) + +``` +cd ruby +ruby stepX_YYY.rb +``` diff --git a/docs/TODO b/docs/TODO index 3e068d7..5b5a240 100644 --- a/docs/TODO +++ b/docs/TODO @@ -5,6 +5,7 @@ All: - hash-map with space in key string (make) - keyword type - gensym reader inside quasiquote + - can let* and quasiquote be TCO'd ? - more interop tests - regular expression matching in runtest @@ -20,18 +21,13 @@ C: - come up with better way to do 20 vararg code C#: - - http://msdn.microsoft.com/en-us/library/ms228362.aspx - - http://www.tutorialspoint.com/csharp - - Readline: - - http://stackoverflow.com/questions/2024170/is-there-a-net-library-similar-to-gnu-readline - - http://tirania.org/blog/archive/2008/Aug-26.html - - https://github.com/deveel/deveelrl - + - step9_interop Clojure: Java: - step9_interop + - store ILambda in function (like c#)? Javascript: @@ -50,10 +46,13 @@ PHP: Postscript: - negative numbers - - debug self-hosting of mal step1 + - fix self-hosting of mal step1 Python: +Ruby: + + --------------------------------------------- @@ -63,6 +62,10 @@ Future Implementations: - http://www.rustforrubyists.com/book/index.html - http://static.rust-lang.org/doc/0.9/complement-cheatsheet.html - http://pzol.github.io/getting_rusty/ + - release notes: + - https://github.com/mozilla/rust/wiki/Doc-detailed-release-notes + - this week in rust: + - http://cmr.github.io/ - readline: - http://redbrain.co.uk/2013/11/09/rust-and-readline-c-ffi/ - http://www.reddit.com/r/rust/comments/1q9pqc/rust_cffi_and_readline/ @@ -72,6 +75,8 @@ Future Implementations: - http://static.rust-lang.org/doc/master/std/hashmap/struct.HashMap.html - vector/list: - http://static.rust-lang.org/doc/master/std/vec/index.html + - example code: + - https://github.com/dradtke/rust-dominion/blob/master/dominion/mod.rs - Redmonk languages from Jan 2014: http://sogrady-media.redmonk.com/sogrady/files/2014/01/lang-rank-114-wm.png diff --git a/java/src/main/java/mal/core.java b/java/src/main/java/mal/core.java index 3200c0e..e1e6705 100644 --- a/java/src/main/java/mal/core.java +++ b/java/src/main/java/mal/core.java @@ -162,9 +162,7 @@ public class core { } }; - // - // Hash map operations - // + // HashMap functions static MalFunction new_hash_map = new MalFunction() { public MalVal apply(MalList a) throws MalThrowable { return new MalHashMap(a); @@ -271,42 +269,22 @@ public class core { static MalFunction cons = new MalFunction() { public MalVal apply(MalList a) throws MalThrowable { - MalList lst = new MalList(); - lst.value.addAll(((MalList)a.nth(1)).value); - lst.value.add(0, a.nth(0)); - return (MalVal) lst; + List lst = new ArrayList(); + lst.add(a.nth(0)); + lst.addAll(((MalList)a.nth(1)).getList()); + return (MalVal)new MalList(lst); } }; static MalFunction concat = new MalFunction() { public MalVal apply(MalList a) throws MalThrowable { if (a.size() == 0) { return new MalList(); } - MalList lst = new MalList(); - lst.value.addAll(((MalList)a.nth(0)).value); + List lst = new ArrayList(); + lst.addAll(((MalList)a.nth(0)).value); for(Integer i=1; i