1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-17 16:47:22 +03:00

Misc cleanup. Move *host-language* to stepA.

This commit is contained in:
Joel Martin 2015-01-02 23:33:50 -06:00
parent f522319598
commit 96f1845afd
12 changed files with 77 additions and 54 deletions

View File

@ -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))))

100
docs/TODO
View File

@ -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
- Visual Basic
aptitude install mono-vbnc
- F#
- 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

View 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

View File

@ -1,4 +1,4 @@
--- step9_try -----------------------------------
--- stepA_interop -------------------------------
import types, reader, printer, env, core
READ(str): return reader.read_str(str)

View File

@ -1,4 +1,4 @@
--- step9_try -----------------------------------
--- stepA_interop -------------------------------
import types, reader, printer, env, core
READ(str): return reader.read_str(str)

View 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):

View File

@ -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*)

View 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

View 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

View 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 }

View 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)]

View 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]