From e6d41de4d5e6259a23874658ba3af1503739f572 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Mon, 15 Jul 2019 23:57:02 +0200 Subject: [PATCH] load-file: accept empty file or final comment, return nil Let `load-file` append a new line in case last line contains a comment. Also append `nil` so that the return value is predictible. Remove the existing explicit `nil` from existing sources. Adapt documentation and tests. --- ada.2/step6_file.adb | 2 +- ada.2/step7_quote.adb | 2 +- ada.2/step8_macros.adb | 2 +- ada.2/step9_try.adb | 2 +- ada.2/stepa_mal.adb | 2 +- ada/step6_file.adb | 2 +- ada/step7_quote.adb | 2 +- ada/step8_macros.adb | 2 +- ada/step9_try.adb | 2 +- ada/stepa_mal.adb | 2 +- awk/step6_file.awk | 2 +- awk/step7_quote.awk | 2 +- awk/step8_macros.awk | 2 +- awk/step9_try.awk | 2 +- awk/stepA_mal.awk | 2 +- bash/step6_file.sh | 2 +- bash/step7_quote.sh | 2 +- bash/step8_macros.sh | 2 +- bash/step9_try.sh | 2 +- bash/stepA_mal.sh | 2 +- basic/step6_file.in.bas | 2 +- basic/step7_quote.in.bas | 2 +- basic/step8_macros.in.bas | 2 +- basic/step9_try.in.bas | 2 +- basic/stepA_mal.in.bas | 2 +- bbc-basic/step6_file.bbc | 2 +- bbc-basic/step7_quote.bbc | 2 +- bbc-basic/step8_macros.bbc | 2 +- bbc-basic/step9_try.bbc | 2 +- bbc-basic/stepA_mal.bbc | 2 +- c/step6_file.c | 2 +- c/step7_quote.c | 2 +- c/step8_macros.c | 2 +- c/step9_try.c | 2 +- c/stepA_mal.c | 2 +- chuck/step6_file.ck | 2 +- chuck/step7_quote.ck | 2 +- chuck/step8_macros.ck | 2 +- chuck/step9_try.ck | 2 +- chuck/stepA_mal.ck | 2 +- clojure/src/mal/step6_file.cljc | 2 +- clojure/src/mal/step7_quote.cljc | 2 +- clojure/src/mal/step8_macros.cljc | 2 +- clojure/src/mal/step9_try.cljc | 2 +- clojure/src/mal/stepA_mal.cljc | 2 +- coffee/step6_file.coffee | 2 +- coffee/step7_quote.coffee | 2 +- coffee/step8_macros.coffee | 2 +- coffee/step9_try.coffee | 2 +- coffee/stepA_mal.coffee | 2 +- common-lisp/src/step6_file.lisp | 2 +- common-lisp/src/step7_quote.lisp | 2 +- common-lisp/src/step8_macros.lisp | 2 +- common-lisp/src/step9_try.lisp | 2 +- common-lisp/src/stepA_mal.lisp | 2 +- cpp/step6_file.cpp | 2 +- cpp/step7_quote.cpp | 2 +- cpp/step8_macros.cpp | 2 +- cpp/step9_try.cpp | 2 +- cpp/stepA_mal.cpp | 2 +- crystal/step6_file.cr | 2 +- crystal/step7_quote.cr | 2 +- crystal/step8_macros.cr | 2 +- crystal/step9_try.cr | 2 +- crystal/stepA_mal.cr | 2 +- cs/step6_file.cs | 2 +- cs/step7_quote.cs | 2 +- cs/step8_macros.cs | 2 +- cs/step9_try.cs | 2 +- cs/stepA_mal.cs | 2 +- d/step6_file.d | 2 +- d/step7_quote.d | 2 +- d/step8_macros.d | 2 +- d/step9_try.d | 2 +- d/stepA_mal.d | 2 +- dart/step6_file.dart | 2 +- dart/step7_quote.dart | 2 +- dart/step8_macros.dart | 2 +- dart/step9_try.dart | 2 +- dart/stepA_mal.dart | 2 +- elisp/step6_file.el | 2 +- elisp/step7_quote.el | 2 +- elisp/step8_macros.el | 2 +- elisp/step9_try.el | 2 +- elisp/stepA_mal.el | 2 +- elixir/lib/mix/tasks/step6_file.ex | 2 +- elixir/lib/mix/tasks/step7_quote.ex | 2 +- elixir/lib/mix/tasks/step8_macros.ex | 2 +- elixir/lib/mix/tasks/step9_try.ex | 2 +- elixir/lib/mix/tasks/stepA_mal.ex | 2 +- elm/step6_file.elm | 2 +- elm/step7_quote.elm | 2 +- elm/step8_macros.elm | 2 +- elm/step9_try.elm | 2 +- elm/stepA_mal.elm | 2 +- erlang/src/step6_file.erl | 2 +- erlang/src/step7_quote.erl | 2 +- erlang/src/step8_macros.erl | 2 +- erlang/src/step9_try.erl | 2 +- erlang/src/stepA_mal.erl | 2 +- es6/step6_file.mjs | 2 +- es6/step7_quote.mjs | 2 +- es6/step8_macros.mjs | 2 +- es6/step9_try.mjs | 2 +- es6/stepA_mal.mjs | 2 +- examples/clojurewest2014.mal | 1 - examples/exercises.mal | 5 ----- examples/presentation.mal | 1 - factor/step6_file/step6_file.factor | 2 +- factor/step7_quote/step7_quote.factor | 2 +- factor/step8_macros/step8_macros.factor | 2 +- factor/step9_try/step9_try.factor | 2 +- factor/stepA_mal/stepA_mal.factor | 2 +- fantom/src/step6_file/fan/main.fan | 2 +- fantom/src/step7_quote/fan/main.fan | 2 +- fantom/src/step8_macros/fan/main.fan | 2 +- fantom/src/step9_try/fan/main.fan | 2 +- fantom/src/stepA_mal/fan/main.fan | 2 +- forth/step6_file.fs | 2 +- forth/step7_quote.fs | 2 +- forth/step8_macros.fs | 2 +- forth/step9_try.fs | 2 +- forth/stepA_mal.fs | 2 +- fsharp/step6_file.fs | 2 +- fsharp/step7_quote.fs | 2 +- fsharp/step8_macros.fs | 2 +- fsharp/step9_try.fs | 2 +- fsharp/stepA_mal.fs | 2 +- gnu-smalltalk/step6_file.st | 2 +- gnu-smalltalk/step7_quote.st | 2 +- gnu-smalltalk/step8_macros.st | 2 +- gnu-smalltalk/step9_try.st | 2 +- gnu-smalltalk/stepA_mal.st | 2 +- go/src/step6_file/step6_file.go | 2 +- go/src/step7_quote/step7_quote.go | 2 +- go/src/step8_macros/step8_macros.go | 2 +- go/src/step9_try/step9_try.go | 2 +- go/src/stepA_mal/stepA_mal.go | 2 +- groovy/step6_file.groovy | 2 +- groovy/step7_quote.groovy | 2 +- groovy/step8_macros.groovy | 2 +- groovy/step9_try.groovy | 2 +- groovy/stepA_mal.groovy | 2 +- guile/step6_file.scm | 2 +- guile/step7_quote.scm | 2 +- guile/step8_macros.scm | 2 +- guile/step9_try.scm | 2 +- guile/stepA_mal.scm | 2 +- haskell/step6_file.hs | 2 +- haskell/step7_quote.hs | 2 +- haskell/step8_macros.hs | 2 +- haskell/step9_try.hs | 2 +- haskell/stepA_mal.hs | 2 +- haxe/Step6_file.hx | 2 +- haxe/Step7_quote.hx | 2 +- haxe/Step8_macros.hx | 2 +- haxe/Step9_try.hx | 2 +- haxe/StepA_mal.hx | 2 +- hy/step6_file.hy | 2 +- hy/step7_quote.hy | 2 +- hy/step8_macros.hy | 2 +- hy/step9_try.hy | 2 +- hy/stepA_mal.hy | 2 +- io/step6_file.io | 2 +- io/step7_quote.io | 2 +- io/step8_macros.io | 2 +- io/step9_try.io | 2 +- io/stepA_mal.io | 2 +- java/src/main/java/mal/step6_file.java | 2 +- java/src/main/java/mal/step7_quote.java | 2 +- java/src/main/java/mal/step8_macros.java | 2 +- java/src/main/java/mal/step9_try.java | 2 +- java/src/main/java/mal/stepA_mal.java | 2 +- js/step6_file.js | 2 +- js/step7_quote.js | 2 +- js/step8_macros.js | 2 +- js/step9_try.js | 2 +- js/stepA_mal.js | 2 +- julia/step6_file.jl | 2 +- julia/step7_quote.jl | 2 +- julia/step8_macros.jl | 2 +- julia/step9_try.jl | 2 +- julia/stepA_mal.jl | 2 +- kotlin/src/mal/step6_file.kt | 2 +- kotlin/src/mal/step7_quote.kt | 2 +- kotlin/src/mal/step8_macros.kt | 2 +- kotlin/src/mal/step9_try.kt | 2 +- kotlin/src/mal/stepA_mal.kt | 2 +- lib/README.md | 3 --- lib/alias-hacks.mal | 4 +--- lib/equality.mal | 2 -- lib/load-file-once.mal | 2 -- lib/memoize.mal | 2 -- lib/perf.mal | 2 -- lib/pprint.mal | 2 -- lib/protocols.mal | 2 -- lib/reducers.mal | 2 -- lib/test_cascade.mal | 2 -- lib/threading.mal | 2 -- lib/trivial.mal | 2 -- livescript/step6_file.ls | 2 +- livescript/step7_quote.ls | 2 +- livescript/step8_macros.ls | 2 +- livescript/step9_try.ls | 2 +- livescript/stepA_mal.ls | 2 +- logo/step6_file.lg | 2 +- logo/step7_quote.lg | 2 +- logo/step8_macros.lg | 2 +- logo/step9_try.lg | 2 +- logo/stepA_mal.lg | 2 +- lua/step6_file.lua | 2 +- lua/step7_quote.lua | 2 +- lua/step8_macros.lua | 2 +- lua/step9_try.lua | 2 +- lua/stepA_mal.lua | 2 +- make/step6_file.mk | 2 +- make/step7_quote.mk | 2 +- make/step8_macros.mk | 2 +- make/step9_try.mk | 2 +- make/stepA_mal.mk | 2 +- mal/step6_file.mal | 2 +- mal/step7_quote.mal | 2 +- mal/step8_macros.mal | 2 +- mal/step9_try.mal | 2 +- mal/stepA_mal.mal | 2 +- matlab/step6_file.m | 2 +- matlab/step7_quote.m | 2 +- matlab/step8_macros.m | 2 +- matlab/step9_try.m | 2 +- matlab/stepA_mal.m | 2 +- miniMAL/step6_file.json | 2 +- miniMAL/step7_quote.json | 2 +- miniMAL/step8_macros.json | 2 +- miniMAL/step9_try.json | 2 +- miniMAL/stepA_mal.json | 2 +- nasm/step6_file.asm | 2 +- nasm/step7_quote.asm | 2 +- nasm/step8_macros.asm | 2 +- nasm/step9_try.asm | 2 +- nasm/stepA_mal.asm | 2 +- nim/step6_file.nim | 2 +- nim/step7_quote.nim | 2 +- nim/step8_macros.nim | 2 +- nim/step9_try.nim | 2 +- nim/stepA_mal.nim | 2 +- objc/step6_file.m | 2 +- objc/step7_quote.m | 2 +- objc/step8_macros.m | 2 +- objc/step9_try.m | 2 +- objc/stepA_mal.m | 2 +- objpascal/step6_file.pas | 2 +- objpascal/step7_quote.pas | 2 +- objpascal/step8_macros.pas | 2 +- objpascal/step9_try.pas | 2 +- objpascal/stepA_mal.pas | 2 +- ocaml/step6_file.ml | 2 +- ocaml/step7_quote.ml | 2 +- ocaml/step8_macros.ml | 2 +- ocaml/step9_try.ml | 2 +- ocaml/stepA_mal.ml | 2 +- perl/step6_file.pl | 2 +- perl/step7_quote.pl | 2 +- perl/step8_macros.pl | 3 +-- perl/step9_try.pl | 3 +-- perl/stepA_mal.pl | 2 +- perl6/step6_file.pl | 2 +- perl6/step7_quote.pl | 2 +- perl6/step8_macros.pl | 2 +- perl6/step9_try.pl | 2 +- perl6/stepA_mal.pl | 2 +- php/step6_file.php | 2 +- php/step7_quote.php | 2 +- php/step8_macros.php | 2 +- php/step9_try.php | 2 +- php/stepA_mal.php | 2 +- picolisp/step6_file.l | 2 +- picolisp/step7_quote.l | 2 +- picolisp/step8_macros.l | 2 +- picolisp/step9_try.l | 2 +- picolisp/stepA_mal.l | 2 +- plpgsql/step6_file.sql | 2 +- plpgsql/step7_quote.sql | 2 +- plpgsql/step8_macros.sql | 2 +- plpgsql/step9_try.sql | 2 +- plpgsql/stepA_mal.sql | 2 +- plsql/step6_file.sql | 2 +- plsql/step7_quote.sql | 2 +- plsql/step8_macros.sql | 2 +- plsql/step9_try.sql | 2 +- plsql/stepA_mal.sql | 2 +- powershell/step6_file.ps1 | 2 +- powershell/step7_quote.ps1 | 2 +- powershell/step8_macros.ps1 | 2 +- powershell/step9_try.ps1 | 2 +- powershell/stepA_mal.ps1 | 2 +- process/guide.md | 6 ++++-- process/step6_file.txt | 2 +- process/step7_quote.txt | 2 +- process/step8_macros.txt | 2 +- process/step9_try.txt | 2 +- process/stepA_mal.txt | 2 +- ps/step6_file.ps | 2 +- ps/step7_quote.ps | 2 +- ps/step8_macros.ps | 2 +- ps/step9_try.ps | 2 +- ps/stepA_mal.ps | 2 +- python/step6_file.py | 2 +- python/step7_quote.py | 2 +- python/step8_macros.py | 2 +- python/step9_try.py | 2 +- python/stepA_mal.py | 2 +- r/step6_file.r | 2 +- r/step7_quote.r | 2 +- r/step8_macros.r | 2 +- r/step9_try.r | 2 +- r/stepA_mal.r | 2 +- racket/step6_file.rkt | 2 +- racket/step7_quote.rkt | 2 +- racket/step8_macros.rkt | 2 +- racket/step9_try.rkt | 2 +- racket/stepA_mal.rkt | 2 +- rexx/step6_file.rexx | 2 +- rexx/step7_quote.rexx | 2 +- rexx/step8_macros.rexx | 2 +- rexx/step9_try.rexx | 2 +- rexx/stepA_mal.rexx | 2 +- rpython/step6_file.py | 2 +- rpython/step7_quote.py | 2 +- rpython/step8_macros.py | 2 +- rpython/step9_try.py | 2 +- rpython/stepA_mal.py | 2 +- ruby/step6_file.rb | 2 +- ruby/step7_quote.rb | 2 +- ruby/step8_macros.rb | 2 +- ruby/step9_try.rb | 2 +- ruby/stepA_mal.rb | 2 +- rust/step6_file.rs | 2 +- rust/step7_quote.rs | 2 +- rust/step8_macros.rs | 2 +- rust/step9_try.rs | 2 +- rust/stepA_mal.rs | 2 +- scala/step6_file.scala | 2 +- scala/step7_quote.scala | 2 +- scala/step8_macros.scala | 2 +- scala/step9_try.scala | 2 +- scala/stepA_mal.scala | 2 +- scheme/step6_file.scm | 2 +- scheme/step7_quote.scm | 2 +- scheme/step8_macros.scm | 2 +- scheme/step9_try.scm | 2 +- scheme/stepA_mal.scm | 2 +- skew/step6_file.sk | 2 +- skew/step7_quote.sk | 2 +- skew/step8_macros.sk | 2 +- skew/step9_try.sk | 2 +- skew/stepA_mal.sk | 2 +- swift/step6_file.swift | 2 +- swift/step7_quote.swift | 2 +- swift/step8_macros.swift | 2 +- swift/step9_try.swift | 2 +- swift/stepA_mal.swift | 2 +- swift3/Sources/step6_file/main.swift | 2 +- swift3/Sources/step7_quote/main.swift | 2 +- swift3/Sources/step8_macros/main.swift | 2 +- swift3/Sources/step9_try/main.swift | 2 +- swift3/Sources/stepA_mal/main.swift | 2 +- swift4/Sources/step6_file/main.swift | 2 +- swift4/Sources/step7_quote/main.swift | 2 +- swift4/Sources/step8_macros/main.swift | 2 +- swift4/Sources/step9_try/main.swift | 2 +- swift4/Sources/stepA_mal/main.swift | 2 +- tcl/step6_file.tcl | 2 +- tcl/step7_quote.tcl | 2 +- tcl/step8_macros.tcl | 2 +- tcl/step9_try.tcl | 2 +- tcl/stepA_mal.tcl | 2 +- tests/computations.mal | 2 -- tests/incB.mal | 6 +----- tests/incC.mal | 4 ---- tests/lib/load-file-once.mal | 6 ++++++ tests/step6_file.mal | 5 +++-- tests/step7_quote.mal | 1 - tests/stepA_mal.mal | 1 + ts/step6_file.ts | 2 +- ts/step7_quote.ts | 2 +- ts/step8_macros.ts | 2 +- ts/step9_try.ts | 2 +- ts/stepA_mal.ts | 2 +- vala/step6_file.vala | 2 +- vala/step7_quote.vala | 2 +- vala/step8_macros.vala | 2 +- vala/step9_try.vala | 2 +- vala/stepA_mal.vala | 2 +- vb/step6_file.vb | 2 +- vb/step7_quote.vb | 2 +- vb/step8_macros.vb | 2 +- vb/step9_try.vb | 2 +- vb/stepA_mal.vb | 2 +- vhdl/step6_file.vhdl | 2 +- vhdl/step7_quote.vhdl | 2 +- vhdl/step8_macros.vhdl | 2 +- vhdl/step9_try.vhdl | 2 +- vhdl/stepA_mal.vhdl | 2 +- vimscript/step6_file.vim | 2 +- vimscript/step7_quote.vim | 2 +- vimscript/step8_macros.vim | 2 +- vimscript/step9_try.vim | 2 +- vimscript/stepA_mal.vim | 2 +- wasm/step6_file.wam | 2 +- wasm/step7_quote.wam | 2 +- wasm/step8_macros.wam | 2 +- wasm/step9_try.wam | 2 +- wasm/stepA_mal.wam | 2 +- yorick/step6_file.i | 2 +- yorick/step7_quote.i | 2 +- yorick/step8_macros.i | 2 +- yorick/step9_try.i | 2 +- yorick/stepA_mal.i | 2 +- 418 files changed, 411 insertions(+), 446 deletions(-) diff --git a/ada.2/step6_file.adb b/ada.2/step6_file.adb index d10488af..18cc6a92 100644 --- a/ada.2/step6_file.adb +++ b/ada.2/step6_file.adb @@ -266,7 +266,7 @@ procedure Step6_File is Startup : constant String := "(def! not (fn* (a) (if a false true)))" & "(def! load-file (fn* (f)" - & " (eval (read-string (str ""(do "" (slurp f) "")"")))))"; + & " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"; Repl : constant Envs.Ptr := Envs.New_Env; function Eval_Builtin (Args : in Types.T_Array) return Types.T is begin diff --git a/ada.2/step7_quote.adb b/ada.2/step7_quote.adb index d3f6d5c5..d27ad01e 100644 --- a/ada.2/step7_quote.adb +++ b/ada.2/step7_quote.adb @@ -346,7 +346,7 @@ procedure Step7_Quote is Startup : constant String := "(def! not (fn* (a) (if a false true)))" & "(def! load-file (fn* (f)" - & " (eval (read-string (str ""(do "" (slurp f) "")"")))))"; + & " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"; Repl : constant Envs.Ptr := Envs.New_Env; function Eval_Builtin (Args : in Types.T_Array) return Types.T is begin diff --git a/ada.2/step8_macros.adb b/ada.2/step8_macros.adb index 4e9db3ec..6233ca4c 100644 --- a/ada.2/step8_macros.adb +++ b/ada.2/step8_macros.adb @@ -395,7 +395,7 @@ procedure Step8_Macros is Startup : constant String := "(def! not (fn* (a) (if a false true)))" & "(def! load-file (fn* (f)" - & " (eval (read-string (str ""(do "" (slurp f) "")"")))))" + & " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))" & "(defmacro! cond (fn* (& xs)" & " (if (> (count xs) 0)" & " (list 'if (first xs)" diff --git a/ada.2/step9_try.adb b/ada.2/step9_try.adb index 162eec10..7c8e3abb 100644 --- a/ada.2/step9_try.adb +++ b/ada.2/step9_try.adb @@ -425,7 +425,7 @@ procedure Step9_Try is Startup : constant String := "(def! not (fn* (a) (if a false true)))" & "(def! load-file (fn* (f)" - & " (eval (read-string (str ""(do "" (slurp f) "")"")))))" + & " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))" & "(defmacro! cond (fn* (& xs)" & " (if (> (count xs) 0)" & " (list 'if (first xs)" diff --git a/ada.2/stepa_mal.adb b/ada.2/stepa_mal.adb index ba52c2c0..3a3d17c6 100644 --- a/ada.2/stepa_mal.adb +++ b/ada.2/stepa_mal.adb @@ -431,7 +431,7 @@ procedure StepA_Mal is Startup : constant String := "(def! not (fn* (a) (if a false true)))" & "(def! load-file (fn* (f)" - & " (eval (read-string (str ""(do "" (slurp f) "")"")))))" + & " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))" & "(defmacro! cond (fn* (& xs)" & " (if (> (count xs) 0)" & " (list 'if (first xs)" diff --git a/ada/step6_file.adb b/ada/step6_file.adb index dbf65347..a02969cc 100644 --- a/ada/step6_file.adb +++ b/ada/step6_file.adb @@ -358,7 +358,7 @@ begin Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access)); RE ("(def! not (fn* (a) (if a false true)))"); - RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))"); + RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"); -- Command line processing. diff --git a/ada/step7_quote.adb b/ada/step7_quote.adb index 848142ae..41308ffa 100644 --- a/ada/step7_quote.adb +++ b/ada/step7_quote.adb @@ -449,7 +449,7 @@ begin Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access)); RE ("(def! not (fn* (a) (if a false true)))"); - RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))"); + RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"); -- Command line processing. diff --git a/ada/step8_macros.adb b/ada/step8_macros.adb index 40e4624c..2c8857eb 100644 --- a/ada/step8_macros.adb +++ b/ada/step8_macros.adb @@ -525,7 +525,7 @@ begin Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access)); RE ("(def! not (fn* (a) (if a false true)))"); - RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))"); + RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"); 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)))))))"); -- Command line processing. diff --git a/ada/step9_try.adb b/ada/step9_try.adb index fcbba5c5..dd01367c 100644 --- a/ada/step9_try.adb +++ b/ada/step9_try.adb @@ -578,7 +578,7 @@ begin Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access)); RE ("(def! not (fn* (a) (if a false true)))"); - RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))"); + RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"); 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)))))))"); -- Command line processing. diff --git a/ada/stepa_mal.adb b/ada/stepa_mal.adb index b0c9c040..ce1c1191 100644 --- a/ada/stepa_mal.adb +++ b/ada/stepa_mal.adb @@ -578,7 +578,7 @@ begin Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access)); RE ("(def! not (fn* (a) (if a false true)))"); - RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))"); + RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"); 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)))))))"); -- Command line processing. diff --git a/awk/step6_file.awk b/awk/step6_file.awk index fec4250f..369bd055 100644 --- a/awk/step6_file.awk +++ b/awk/step6_file.awk @@ -325,7 +325,7 @@ function main(str, ret, i, idx) env_set(repl_env, "'eval", "&eval") rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") idx = types_allocate() env_set(repl_env, "'*ARGV*", "(" idx) diff --git a/awk/step7_quote.awk b/awk/step7_quote.awk index f199442a..d8e963e2 100644 --- a/awk/step7_quote.awk +++ b/awk/step7_quote.awk @@ -415,7 +415,7 @@ function main(str, ret, i, idx) env_set(repl_env, "'eval", "&eval") rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") idx = types_allocate() env_set(repl_env, "'*ARGV*", "(" idx) diff --git a/awk/step8_macros.awk b/awk/step8_macros.awk index 85fe014c..6e4a4723 100644 --- a/awk/step8_macros.awk +++ b/awk/step8_macros.awk @@ -505,7 +505,7 @@ function main(str, ret, i, idx) env_set(repl_env, "'eval", "&eval") rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") 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)))))))") idx = types_allocate() diff --git a/awk/step9_try.awk b/awk/step9_try.awk index 18583c67..f30b2ca4 100644 --- a/awk/step9_try.awk +++ b/awk/step9_try.awk @@ -567,7 +567,7 @@ function main(str, ret, i, idx) env_set(repl_env, "'eval", "&eval") rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") 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)))))))") idx = types_allocate() diff --git a/awk/stepA_mal.awk b/awk/stepA_mal.awk index ce5773b5..bb097eed 100644 --- a/awk/stepA_mal.awk +++ b/awk/stepA_mal.awk @@ -570,7 +570,7 @@ function main(str, ret, i, idx) rep("(def! *host-language* \"GNU awk\")") rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") 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)))))))") idx = types_allocate() diff --git a/bash/step6_file.sh b/bash/step6_file.sh index d1e7f118..4d430883 100755 --- a/bash/step6_file.sh +++ b/bash/step6_file.sh @@ -161,7 +161,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}"; # core.mal: defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" # load/run file from command line (then exit) if [[ "${1}" ]]; then diff --git a/bash/step7_quote.sh b/bash/step7_quote.sh index c90074c1..fce62c09 100755 --- a/bash/step7_quote.sh +++ b/bash/step7_quote.sh @@ -206,7 +206,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}"; # core.mal: defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" # load/run file from command line (then exit) if [[ "${1}" ]]; then diff --git a/bash/step8_macros.sh b/bash/step8_macros.sh index 72b010da..a3c6e98a 100755 --- a/bash/step8_macros.sh +++ b/bash/step8_macros.sh @@ -248,7 +248,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}"; # core.mal: defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" 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)))))))" # load/run file from command line (then exit) diff --git a/bash/step9_try.sh b/bash/step9_try.sh index 29fa329b..dc5aa974 100755 --- a/bash/step9_try.sh +++ b/bash/step9_try.sh @@ -261,7 +261,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}"; # core.mal: defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" 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)))))))" # load/run file from command line (then exit) diff --git a/bash/stepA_mal.sh b/bash/stepA_mal.sh index e414b7ab..f1e63d3f 100755 --- a/bash/stepA_mal.sh +++ b/bash/stepA_mal.sh @@ -270,7 +270,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}"; # core.mal: defined using the language itself REP "(def! *host-language* \"bash\")" REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" 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)))))))" # load/run file from command line (then exit) diff --git a/basic/step6_file.in.bas b/basic/step6_file.in.bas index a5c28db0..61e9b0ed 100755 --- a/basic/step6_file.in.bas +++ b/basic/step6_file.in.bas @@ -372,7 +372,7 @@ MAIN: A$="(def! not (fn* (a) (if a false true)))" GOSUB RE:AY=R:GOSUB RELEASE - A$="(def! load-file (fn* (f) (eval (read-file f))))" + A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))" GOSUB RE:AY=R:GOSUB RELEASE REM load the args file diff --git a/basic/step7_quote.in.bas b/basic/step7_quote.in.bas index 86689a13..8233f089 100755 --- a/basic/step7_quote.in.bas +++ b/basic/step7_quote.in.bas @@ -462,7 +462,7 @@ MAIN: A$="(def! not (fn* (a) (if a false true)))" GOSUB RE:AY=R:GOSUB RELEASE - A$="(def! load-file (fn* (f) (eval (read-file f))))" + A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))" GOSUB RE:AY=R:GOSUB RELEASE REM load the args file diff --git a/basic/step8_macros.in.bas b/basic/step8_macros.in.bas index ed1733d0..347ebf69 100755 --- a/basic/step8_macros.in.bas +++ b/basic/step8_macros.in.bas @@ -529,7 +529,7 @@ MAIN: A$="(def! not (fn* (a) (if a false true)))" GOSUB RE:AY=R:GOSUB RELEASE - A$="(def! load-file (fn* (f) (eval (read-file f))))" + A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))" GOSUB RE:AY=R:GOSUB RELEASE A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)" diff --git a/basic/step9_try.in.bas b/basic/step9_try.in.bas index 25a22c9b..ac0bbf84 100755 --- a/basic/step9_try.in.bas +++ b/basic/step9_try.in.bas @@ -562,7 +562,7 @@ MAIN: A$="(def! not (fn* (a) (if a false true)))" GOSUB RE:AY=R:GOSUB RELEASE - A$="(def! load-file (fn* (f) (eval (read-file f))))" + A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))" GOSUB RE:AY=R:GOSUB RELEASE A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)" diff --git a/basic/stepA_mal.in.bas b/basic/stepA_mal.in.bas index 132957d4..2b4e8a6d 100755 --- a/basic/stepA_mal.in.bas +++ b/basic/stepA_mal.in.bas @@ -561,7 +561,7 @@ MAIN: A$="(def! not (fn* (a) (if a false true)))" GOSUB RE:AY=R:GOSUB RELEASE - A$="(def! load-file (fn* (f) (eval (read-file f))))" + A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))" GOSUB RE:AY=R:GOSUB RELEASE A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)" diff --git a/bbc-basic/step6_file.bbc b/bbc-basic/step6_file.bbc index 78d95191..6c682b21 100644 --- a/bbc-basic/step6_file.bbc +++ b/bbc-basic/step6_file.bbc @@ -20,7 +20,7 @@ UNTIL sym$ = "" REM Initial forms to evaluate RESTORE +0 DATA (def! not (fn* (a) (if a false true))) -DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) +DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) DATA "" REPEAT READ form$ diff --git a/bbc-basic/step7_quote.bbc b/bbc-basic/step7_quote.bbc index faa2c603..bfab04b4 100644 --- a/bbc-basic/step7_quote.bbc +++ b/bbc-basic/step7_quote.bbc @@ -20,7 +20,7 @@ UNTIL sym$ = "" REM Initial forms to evaluate RESTORE +0 DATA (def! not (fn* (a) (if a false true))) -DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) +DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) DATA "" REPEAT READ form$ diff --git a/bbc-basic/step8_macros.bbc b/bbc-basic/step8_macros.bbc index 5e9be483..7cddc5af 100644 --- a/bbc-basic/step8_macros.bbc +++ b/bbc-basic/step8_macros.bbc @@ -20,7 +20,7 @@ UNTIL sym$ = "" REM Initial forms to evaluate RESTORE +0 DATA (def! not (fn* (a) (if a false true))) -DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) +DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) DATA (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))))))) DATA "" REPEAT diff --git a/bbc-basic/step9_try.bbc b/bbc-basic/step9_try.bbc index f6524e3a..1fa6323d 100644 --- a/bbc-basic/step9_try.bbc +++ b/bbc-basic/step9_try.bbc @@ -20,7 +20,7 @@ UNTIL sym$ = "" REM Initial forms to evaluate RESTORE +0 DATA (def! not (fn* (a) (if a false true))) -DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) +DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) DATA (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))))))) DATA "" REPEAT diff --git a/bbc-basic/stepA_mal.bbc b/bbc-basic/stepA_mal.bbc index 44c990cb..40b2ef26 100644 --- a/bbc-basic/stepA_mal.bbc +++ b/bbc-basic/stepA_mal.bbc @@ -20,7 +20,7 @@ UNTIL sym$ = "" REM Initial forms to evaluate RESTORE +0 DATA (def! not (fn* (a) (if a false true))) -DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) +DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) DATA (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))))))) DATA (def! *host-language* "BBC BASIC V") DATA "" diff --git a/c/step6_file.c b/c/step6_file.c index 2feb873c..e7388c87 100644 --- a/c/step6_file.c +++ b/c/step6_file.c @@ -210,7 +210,7 @@ void init_repl_env(int argc, char *argv[]) { // core.mal: defined using the language itself RE(repl_env, "", "(def! not (fn* (a) (if a false true)))"); RE(repl_env, "", - "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); } int main(int argc, char *argv[]) diff --git a/c/step7_quote.c b/c/step7_quote.c index 2a601b99..844a3ed9 100644 --- a/c/step7_quote.c +++ b/c/step7_quote.c @@ -247,7 +247,7 @@ void init_repl_env(int argc, char *argv[]) { // core.mal: defined using the language itself RE(repl_env, "", "(def! not (fn* (a) (if a false true)))"); RE(repl_env, "", - "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); } int main(int argc, char *argv[]) diff --git a/c/step8_macros.c b/c/step8_macros.c index 5dede971..a7953361 100644 --- a/c/step8_macros.c +++ b/c/step8_macros.c @@ -289,7 +289,7 @@ void init_repl_env(int argc, char *argv[]) { // core.mal: defined using the language itself RE(repl_env, "", "(def! not (fn* (a) (if a false true)))"); RE(repl_env, "", - "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); RE(repl_env, "", "(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)))))))"); } diff --git a/c/step9_try.c b/c/step9_try.c index c4d262fe..3bfbcb6f 100644 --- a/c/step9_try.c +++ b/c/step9_try.c @@ -314,7 +314,7 @@ void init_repl_env(int argc, char *argv[]) { // core.mal: defined using the language itself RE(repl_env, "", "(def! not (fn* (a) (if a false true)))"); RE(repl_env, "", - "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); RE(repl_env, "", "(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)))))))"); } diff --git a/c/stepA_mal.c b/c/stepA_mal.c index 2c8f6b0d..41ad4d35 100644 --- a/c/stepA_mal.c +++ b/c/stepA_mal.c @@ -320,7 +320,7 @@ void init_repl_env(int argc, char *argv[]) { RE(repl_env, "", "(def! *host-language* \"c\")"); RE(repl_env, "", "(def! not (fn* (a) (if a false true)))"); RE(repl_env, "", - "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); RE(repl_env, "", "(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)))))))"); } diff --git a/chuck/step6_file.ck b/chuck/step6_file.ck index 5d1c55f8..fdfe701b 100644 --- a/chuck/step6_file.ck +++ b/chuck/step6_file.ck @@ -308,7 +308,7 @@ fun string rep(string input) } rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); fun void main() { diff --git a/chuck/step7_quote.ck b/chuck/step7_quote.ck index 6470456a..004d5f78 100644 --- a/chuck/step7_quote.ck +++ b/chuck/step7_quote.ck @@ -363,7 +363,7 @@ fun string rep(string input) } rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); fun void main() { diff --git a/chuck/step8_macros.ck b/chuck/step8_macros.ck index 5c185d91..83838764 100644 --- a/chuck/step8_macros.ck +++ b/chuck/step8_macros.ck @@ -434,7 +434,7 @@ fun string rep(string input) } rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); fun void main() diff --git a/chuck/step9_try.ck b/chuck/step9_try.ck index ecc45d8b..bbc8f4f9 100644 --- a/chuck/step9_try.ck +++ b/chuck/step9_try.ck @@ -451,7 +451,7 @@ fun string rep(string input) } rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); fun void main() diff --git a/chuck/stepA_mal.ck b/chuck/stepA_mal.ck index afe6b8d7..154ae65f 100644 --- a/chuck/stepA_mal.ck +++ b/chuck/stepA_mal.ck @@ -453,7 +453,7 @@ fun string rep(string input) } rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); fun void main() diff --git a/clojure/src/mal/step6_file.cljc b/clojure/src/mal/step6_file.cljc index 6e9ac762..d81a291a 100644 --- a/clojure/src/mal/step6_file.cljc +++ b/clojure/src/mal/step6_file.cljc @@ -94,7 +94,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") ;; repl loop (defn repl-loop [] diff --git a/clojure/src/mal/step7_quote.cljc b/clojure/src/mal/step7_quote.cljc index f1eccfed..647d559a 100644 --- a/clojure/src/mal/step7_quote.cljc +++ b/clojure/src/mal/step7_quote.cljc @@ -117,7 +117,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") ;; repl loop (defn repl-loop [] diff --git a/clojure/src/mal/step8_macros.cljc b/clojure/src/mal/step8_macros.cljc index d0d56741..3949dd11 100644 --- a/clojure/src/mal/step8_macros.cljc +++ b/clojure/src/mal/step8_macros.cljc @@ -151,7 +151,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ;; repl loop diff --git a/clojure/src/mal/step9_try.cljc b/clojure/src/mal/step9_try.cljc index fd172375..3b8cd044 100644 --- a/clojure/src/mal/step9_try.cljc +++ b/clojure/src/mal/step9_try.cljc @@ -168,7 +168,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ;; repl loop diff --git a/clojure/src/mal/stepA_mal.cljc b/clojure/src/mal/stepA_mal.cljc index 5a26159a..8b433e26 100644 --- a/clojure/src/mal/stepA_mal.cljc +++ b/clojure/src/mal/stepA_mal.cljc @@ -178,7 +178,7 @@ #?(:clj (rep "(def! *host-language* \"clojure\")") :cljs (rep "(def! *host-language* \"clojurescript\")")) (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ;; repl loop diff --git a/coffee/step6_file.coffee b/coffee/step6_file.coffee index b1b786c1..eccb2bd4 100644 --- a/coffee/step6_file.coffee +++ b/coffee/step6_file.coffee @@ -71,7 +71,7 @@ repl_env.set types._symbol('*ARGV*'), [] # core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if process? && process.argv.length > 2 repl_env.set types._symbol('*ARGV*'), process.argv[3..] diff --git a/coffee/step7_quote.coffee b/coffee/step7_quote.coffee index bde2a879..21bf3aa9 100644 --- a/coffee/step7_quote.coffee +++ b/coffee/step7_quote.coffee @@ -87,7 +87,7 @@ repl_env.set types._symbol('*ARGV*'), [] # core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if process? && process.argv.length > 2 repl_env.set types._symbol('*ARGV*'), process.argv[3..] diff --git a/coffee/step8_macros.coffee b/coffee/step8_macros.coffee index 98319a10..1e7dc61e 100644 --- a/coffee/step8_macros.coffee +++ b/coffee/step8_macros.coffee @@ -105,7 +105,7 @@ repl_env.set types._symbol('*ARGV*'), [] # core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 process? && process.argv.length > 2 diff --git a/coffee/step9_try.coffee b/coffee/step9_try.coffee index 71d479ed..8cde5126 100644 --- a/coffee/step9_try.coffee +++ b/coffee/step9_try.coffee @@ -114,7 +114,7 @@ repl_env.set types._symbol('*ARGV*'), [] # core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 process? && process.argv.length > 2 diff --git a/coffee/stepA_mal.coffee b/coffee/stepA_mal.coffee index 7f0030b3..082aa0b9 100644 --- a/coffee/stepA_mal.coffee +++ b/coffee/stepA_mal.coffee @@ -121,7 +121,7 @@ repl_env.set types._symbol('*ARGV*'), [] # core.mal: defined using the language itself rep("(def! *host-language* \"CoffeeScript\")") rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 process? && process.argv.length > 2 diff --git a/common-lisp/src/step6_file.lisp b/common-lisp/src/step6_file.lisp index 75b3621a..bf245787 100644 --- a/common-lisp/src/step6_file.lisp +++ b/common-lisp/src/step6_file.lisp @@ -135,7 +135,7 @@ (mal-eval ast *repl-env*)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") (defvar *use-readline-p* nil) diff --git a/common-lisp/src/step7_quote.lisp b/common-lisp/src/step7_quote.lisp index cf92fc50..d39cf5a4 100644 --- a/common-lisp/src/step7_quote.lisp +++ b/common-lisp/src/step7_quote.lisp @@ -171,7 +171,7 @@ (mal-eval ast *repl-env*)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") (defvar *use-readline-p* nil) diff --git a/common-lisp/src/step8_macros.lisp b/common-lisp/src/step8_macros.lisp index ab75d9c6..75149d59 100644 --- a/common-lisp/src/step8_macros.lisp +++ b/common-lisp/src/step8_macros.lisp @@ -226,7 +226,7 @@ (mal-eval ast *repl-env*)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") (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)))))))") (defvar *use-readline-p* nil) diff --git a/common-lisp/src/step9_try.lisp b/common-lisp/src/step9_try.lisp index d8bd04d8..b05c3614 100644 --- a/common-lisp/src/step9_try.lisp +++ b/common-lisp/src/step9_try.lisp @@ -249,7 +249,7 @@ (mal-eval ast *repl-env*)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") (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)))))))") (defvar *use-readline-p* nil) diff --git a/common-lisp/src/stepA_mal.lisp b/common-lisp/src/stepA_mal.lisp index adb17bfb..b4873987 100644 --- a/common-lisp/src/stepA_mal.lisp +++ b/common-lisp/src/stepA_mal.lisp @@ -256,7 +256,7 @@ (make-mal-string (lisp-implementation-version))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))") (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 "(def! *host-language* \"common-lisp\")") diff --git a/cpp/step6_file.cpp b/cpp/step6_file.cpp index 8bb47168..ad16f6db 100644 --- a/cpp/step6_file.cpp +++ b/cpp/step6_file.cpp @@ -177,7 +177,7 @@ malValuePtr APPLY(malValuePtr op, malValueIter argsBegin, malValueIter argsEnd) static const char* malFunctionTable[] = { "(def! not (fn* (cond) (if cond false true)))", "(def! load-file (fn* (filename) \ - (eval (read-string (str \"(do \" (slurp filename) \")\")))))", + (eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))", }; static void installFunctions(malEnvPtr env) { diff --git a/cpp/step7_quote.cpp b/cpp/step7_quote.cpp index 61e57941..d094c5f7 100644 --- a/cpp/step7_quote.cpp +++ b/cpp/step7_quote.cpp @@ -235,7 +235,7 @@ static malValuePtr quasiquote(malValuePtr obj) static const char* malFunctionTable[] = { "(def! not (fn* (cond) (if cond false true)))", "(def! load-file (fn* (filename) \ - (eval (read-string (str \"(do \" (slurp filename) \")\")))))", + (eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))", }; static void installFunctions(malEnvPtr env) { diff --git a/cpp/step8_macros.cpp b/cpp/step8_macros.cpp index 183039d2..671dc488 100644 --- a/cpp/step8_macros.cpp +++ b/cpp/step8_macros.cpp @@ -282,7 +282,7 @@ static const char* malFunctionTable[] = { "(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! not (fn* (cond) (if cond false true)))", "(def! load-file (fn* (filename) \ - (eval (read-string (str \"(do \" (slurp filename) \")\")))))", + (eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))", }; static void installFunctions(malEnvPtr env) { diff --git a/cpp/step9_try.cpp b/cpp/step9_try.cpp index ea9f8ce5..064f4e27 100644 --- a/cpp/step9_try.cpp +++ b/cpp/step9_try.cpp @@ -331,7 +331,7 @@ static const char* malFunctionTable[] = { "(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! not (fn* (cond) (if cond false true)))", "(def! load-file (fn* (filename) \ - (eval (read-string (str \"(do \" (slurp filename) \")\")))))", + (eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))", }; static void installFunctions(malEnvPtr env) { diff --git a/cpp/stepA_mal.cpp b/cpp/stepA_mal.cpp index 15ab8192..30aa9994 100644 --- a/cpp/stepA_mal.cpp +++ b/cpp/stepA_mal.cpp @@ -332,7 +332,7 @@ static const char* malFunctionTable[] = { "(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! not (fn* (cond) (if cond false true)))", "(def! load-file (fn* (filename) \ - (eval (read-string (str \"(do \" (slurp filename) \")\")))))", + (eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))", "(def! *host-language* \"C++\")", }; diff --git a/crystal/step6_file.cr b/crystal/step6_file.cr index 12f60792..37788e6a 100755 --- a/crystal/step6_file.cr +++ b/crystal/step6_file.cr @@ -157,7 +157,7 @@ REPL_ENV = Mal::Env.new nil Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) } REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) }) Mal.rep "(def! not (fn* (a) (if a false true)))" -Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" argv = Mal::List.new REPL_ENV.set("*ARGV*", Mal::Type.new argv) diff --git a/crystal/step7_quote.cr b/crystal/step7_quote.cr index 3cb80a67..4a0618a9 100755 --- a/crystal/step7_quote.cr +++ b/crystal/step7_quote.cr @@ -183,7 +183,7 @@ REPL_ENV = Mal::Env.new nil Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) } REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) }) Mal.rep "(def! not (fn* (a) (if a false true)))" -Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" argv = Mal::List.new REPL_ENV.set("*ARGV*", Mal::Type.new argv) diff --git a/crystal/step8_macros.cr b/crystal/step8_macros.cr index d118c15f..1eb219e2 100755 --- a/crystal/step8_macros.cr +++ b/crystal/step8_macros.cr @@ -229,7 +229,7 @@ REPL_ENV = Mal::Env.new nil Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) } REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) }) Mal.rep "(def! not (fn* (a) (if a false true)))" -Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" Mal.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)))))))" argv = Mal::List.new diff --git a/crystal/step9_try.cr b/crystal/step9_try.cr index 455c31e1..d56f1493 100755 --- a/crystal/step9_try.cr +++ b/crystal/step9_try.cr @@ -246,7 +246,7 @@ REPL_ENV = Mal::Env.new nil Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) } REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) }) Mal.rep "(def! not (fn* (a) (if a false true)))" -Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" Mal.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)))))))" argv = Mal::List.new diff --git a/crystal/stepA_mal.cr b/crystal/stepA_mal.cr index 2d7b39b8..eb0aa790 100755 --- a/crystal/stepA_mal.cr +++ b/crystal/stepA_mal.cr @@ -252,7 +252,7 @@ REPL_ENV = Mal::Env.new nil Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) } REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) }) Mal.rep "(def! not (fn* (a) (if a false true)))" -Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" Mal.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)))))))" Mal.rep("(def! *host-language* \"crystal\")") diff --git a/cs/step6_file.cs b/cs/step6_file.cs index 361de6ba..2569b0f4 100644 --- a/cs/step6_file.cs +++ b/cs/step6_file.cs @@ -154,7 +154,7 @@ namespace Mal { // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))"); - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (args.Length > fileIdx) { RE("(load-file \"" + args[fileIdx] + "\")"); diff --git a/cs/step7_quote.cs b/cs/step7_quote.cs index 0940ae89..4131c487 100644 --- a/cs/step7_quote.cs +++ b/cs/step7_quote.cs @@ -186,7 +186,7 @@ namespace Mal { // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))"); - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (args.Length > fileIdx) { RE("(load-file \"" + args[fileIdx] + "\")"); diff --git a/cs/step8_macros.cs b/cs/step8_macros.cs index 6c1d7062..d4e2c6bf 100644 --- a/cs/step8_macros.cs +++ b/cs/step8_macros.cs @@ -225,7 +225,7 @@ namespace Mal { // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))"); - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); if (args.Length > fileIdx) { diff --git a/cs/step9_try.cs b/cs/step9_try.cs index 0a8f746f..1f73c552 100644 --- a/cs/step9_try.cs +++ b/cs/step9_try.cs @@ -246,7 +246,7 @@ namespace Mal { // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))"); - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); if (args.Length > fileIdx) { diff --git a/cs/stepA_mal.cs b/cs/stepA_mal.cs index 70fc0d22..1d0ab4e9 100644 --- a/cs/stepA_mal.cs +++ b/cs/stepA_mal.cs @@ -247,7 +247,7 @@ namespace Mal { // core.mal: defined using the language itself RE("(def! *host-language* \"c#\")"); RE("(def! not (fn* (a) (if a false true)))"); - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); if (args.Length > fileIdx) { diff --git a/d/step6_file.d b/d/step6_file.d index 6408dc89..321b90b0 100644 --- a/d/step6_file.d +++ b/d/step6_file.d @@ -178,7 +178,7 @@ void main(string[] args) // core.mal: defined using the language itself re("(def! not (fn* (a) (if a false true)))", repl_env); - re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); if (args.length > 1) { diff --git a/d/step7_quote.d b/d/step7_quote.d index 64ff7004..6917fc45 100644 --- a/d/step7_quote.d +++ b/d/step7_quote.d @@ -217,7 +217,7 @@ void main(string[] args) // core.mal: defined using the language itself re("(def! not (fn* (a) (if a false true)))", repl_env); - re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); if (args.length > 1) { diff --git a/d/step8_macros.d b/d/step8_macros.d index a39ff89d..01e9432a 100644 --- a/d/step8_macros.d +++ b/d/step8_macros.d @@ -261,7 +261,7 @@ void main(string[] args) // core.mal: defined using the language itself re("(def! not (fn* (a) (if a false true)))", repl_env); - re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); 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)))))))", repl_env); if (args.length > 1) diff --git a/d/step9_try.d b/d/step9_try.d index 054b38e1..d06a0a4b 100644 --- a/d/step9_try.d +++ b/d/step9_try.d @@ -290,7 +290,7 @@ void main(string[] args) // core.mal: defined using the language itself re("(def! not (fn* (a) (if a false true)))", repl_env); - re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); 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)))))))", repl_env); if (args.length > 1) diff --git a/d/stepA_mal.d b/d/stepA_mal.d index 31658e53..eddf2feb 100644 --- a/d/stepA_mal.d +++ b/d/stepA_mal.d @@ -292,7 +292,7 @@ void main(string[] args) // core.mal: defined using the language itself re("(def! *host-language* \"" ~ std.compiler.name ~ "\")", repl_env); re("(def! not (fn* (a) (if a false true)))", repl_env); - re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); 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)))))))", repl_env); if (args.length > 1) diff --git a/dart/step6_file.dart b/dart/step6_file.dart index c33a1740..3fee92d3 100644 --- a/dart/step6_file.dart +++ b/dart/step6_file.dart @@ -20,7 +20,7 @@ void setupEnv(List argv) { rep('(def! not (fn* (a) (if a false true)))'); rep("(def! load-file " - "(fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); } MalType READ(String x) => reader.read_str(x); diff --git a/dart/step7_quote.dart b/dart/step7_quote.dart index 02b07bb0..f32a4900 100644 --- a/dart/step7_quote.dart +++ b/dart/step7_quote.dart @@ -20,7 +20,7 @@ void setupEnv(List argv) { rep('(def! not (fn* (a) (if a false true)))'); rep("(def! load-file " - "(fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + "(fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); } MalType quasiquote(MalType ast) { diff --git a/dart/step8_macros.dart b/dart/step8_macros.dart index a8baada8..ba712cc2 100644 --- a/dart/step8_macros.dart +++ b/dart/step8_macros.dart @@ -19,7 +19,7 @@ void setupEnv(List argv) { rep('(def! not (fn* (a) (if a false true)))'); rep("(def! load-file " - " (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + " (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); rep("(defmacro! cond " " (fn* (& xs) (if (> (count xs) 0) " " (list 'if (first xs) " diff --git a/dart/step9_try.dart b/dart/step9_try.dart index 76cd7523..63db07f0 100644 --- a/dart/step9_try.dart +++ b/dart/step9_try.dart @@ -19,7 +19,7 @@ void setupEnv(List argv) { rep('(def! not (fn* (a) (if a false true)))'); rep("(def! load-file " - " (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + " (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); rep("(defmacro! cond " " (fn* (& xs) (if (> (count xs) 0) " " (list 'if (first xs) " diff --git a/dart/stepA_mal.dart b/dart/stepA_mal.dart index 72ff326a..d1533665 100644 --- a/dart/stepA_mal.dart +++ b/dart/stepA_mal.dart @@ -21,7 +21,7 @@ void setupEnv(List argv) { rep('(def! not (fn* (a) (if a false true)))'); rep("(def! load-file " - " (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + " (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); rep("(defmacro! cond " " (fn* (& xs) (if (> (count xs) 0) " " (list 'if (first xs) " diff --git a/elisp/step6_file.el b/elisp/step6_file.el index 5a5ebb2a..9a7ea686 100644 --- a/elisp/step6_file.el +++ b/elisp/step6_file.el @@ -117,7 +117,7 @@ (PRINT (EVAL (READ input) repl-env))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (defun readln (prompt) ;; C-d throws an error diff --git a/elisp/step7_quote.el b/elisp/step7_quote.el index f5dfce60..d56f31fa 100644 --- a/elisp/step7_quote.el +++ b/elisp/step7_quote.el @@ -150,7 +150,7 @@ (PRINT (EVAL (READ input) repl-env))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (defun readln (prompt) ;; C-d throws an error diff --git a/elisp/step8_macros.el b/elisp/step8_macros.el index 26c5f445..2f1d74fc 100644 --- a/elisp/step8_macros.el +++ b/elisp/step8_macros.el @@ -180,7 +180,7 @@ (PRINT (EVAL (READ input) repl-env))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (defun readln (prompt) diff --git a/elisp/step9_try.el b/elisp/step9_try.el index 289478d9..8360e060 100644 --- a/elisp/step9_try.el +++ b/elisp/step9_try.el @@ -196,7 +196,7 @@ (PRINT (EVAL (READ input) repl-env))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (defun readln (prompt) diff --git a/elisp/stepA_mal.el b/elisp/stepA_mal.el index c4ae1cc4..617dd62a 100644 --- a/elisp/stepA_mal.el +++ b/elisp/stepA_mal.el @@ -197,7 +197,7 @@ (PRINT (EVAL (READ input) repl-env))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (defun readln (prompt) diff --git a/elixir/lib/mix/tasks/step6_file.ex b/elixir/lib/mix/tasks/step6_file.ex index da486b0f..e153771d 100644 --- a/elixir/lib/mix/tasks/step6_file.ex +++ b/elixir/lib/mix/tasks/step6_file.ex @@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step6File do read_eval_print(""" (def! load-file (fn* (f) - (eval (read-string (str "(do " (slurp f) ")"))))) + (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """, env) Mal.Env.set(env, "eval", %Function{value: fn [ast] -> diff --git a/elixir/lib/mix/tasks/step7_quote.ex b/elixir/lib/mix/tasks/step7_quote.ex index bd615e8d..195cb264 100644 --- a/elixir/lib/mix/tasks/step7_quote.ex +++ b/elixir/lib/mix/tasks/step7_quote.ex @@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step7Quote do read_eval_print(""" (def! load-file (fn* (f) - (eval (read-string (str "(do " (slurp f) ")"))))) + (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """, env) Mal.Env.set(env, "eval", %Function{value: fn [ast] -> diff --git a/elixir/lib/mix/tasks/step8_macros.ex b/elixir/lib/mix/tasks/step8_macros.ex index 45edae19..d78e832f 100644 --- a/elixir/lib/mix/tasks/step8_macros.ex +++ b/elixir/lib/mix/tasks/step8_macros.ex @@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step8Macros do read_eval_print(""" (def! load-file (fn* (f) - (eval (read-string (str "(do " (slurp f) ")"))))) + (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """, env) # cond diff --git a/elixir/lib/mix/tasks/step9_try.ex b/elixir/lib/mix/tasks/step9_try.ex index 917b2a2e..4fb61a53 100644 --- a/elixir/lib/mix/tasks/step9_try.ex +++ b/elixir/lib/mix/tasks/step9_try.ex @@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step9Try do read_eval_print(""" (def! load-file (fn* (f) - (eval (read-string (str "(do " (slurp f) ")"))))) + (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """, env) # cond diff --git a/elixir/lib/mix/tasks/stepA_mal.ex b/elixir/lib/mix/tasks/stepA_mal.ex index 340be5a3..b0eaf1e2 100644 --- a/elixir/lib/mix/tasks/stepA_mal.ex +++ b/elixir/lib/mix/tasks/stepA_mal.ex @@ -35,7 +35,7 @@ defmodule Mix.Tasks.StepAMal do read_eval_print(""" (def! load-file (fn* (f) - (eval (read-string (str "(do " (slurp f) ")"))))) + (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """, env) # cond diff --git a/elm/step6_file.elm b/elm/step6_file.elm index d19c501d..d1b3e842 100644 --- a/elm/step6_file.elm +++ b/elm/step6_file.elm @@ -71,7 +71,7 @@ malInit = , """(def! load-file (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))""" + (str "(do " (slurp f) "\nnil)")))))""" ] diff --git a/elm/step7_quote.elm b/elm/step7_quote.elm index 489c701c..4d8f998f 100644 --- a/elm/step7_quote.elm +++ b/elm/step7_quote.elm @@ -71,7 +71,7 @@ malInit = , """(def! load-file (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))""" + (str "(do " (slurp f) "\nnil)")))))""" ] diff --git a/elm/step8_macros.elm b/elm/step8_macros.elm index 85d57ce9..39500123 100644 --- a/elm/step8_macros.elm +++ b/elm/step8_macros.elm @@ -71,7 +71,7 @@ malInit = , """(def! load-file (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))""" + (str "(do " (slurp f) "\nnil)")))))""" , """(defmacro! cond (fn* (& xs) (if (> (count xs) 0) diff --git a/elm/step9_try.elm b/elm/step9_try.elm index ed7d9f71..aadd128b 100644 --- a/elm/step9_try.elm +++ b/elm/step9_try.elm @@ -71,7 +71,7 @@ malInit = , """(def! load-file (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))""" + (str "(do " (slurp f) "\nnil)")))))""" , """(defmacro! cond (fn* (& xs) (if (> (count xs) 0) diff --git a/elm/stepA_mal.elm b/elm/stepA_mal.elm index 2c7f72f7..54d74c1f 100644 --- a/elm/stepA_mal.elm +++ b/elm/stepA_mal.elm @@ -72,7 +72,7 @@ malInit = , """(def! load-file (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))""" + (str "(do " (slurp f) "\nnil)")))))""" , """(defmacro! cond (fn* (& xs) (if (> (count xs) 0) diff --git a/erlang/src/step6_file.erl b/erlang/src/step6_file.erl index 4b1ea4d8..0a37f26c 100644 --- a/erlang/src/step6_file.erl +++ b/erlang/src/step6_file.erl @@ -19,7 +19,7 @@ init() -> Env = core:ns(), % define the load-file and not functions using mal itself eval(read("(def! not (fn* (a) (if a false true)))"), Env), - eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env), + eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env), Env. loop(Env) -> diff --git a/erlang/src/step7_quote.erl b/erlang/src/step7_quote.erl index 3ad11910..9cbeb83b 100644 --- a/erlang/src/step7_quote.erl +++ b/erlang/src/step7_quote.erl @@ -19,7 +19,7 @@ init() -> Env = core:ns(), % define the load-file and not functions using mal itself eval(read("(def! not (fn* (a) (if a false true)))"), Env), - eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env), + eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env), Env. loop(Env) -> diff --git a/erlang/src/step8_macros.erl b/erlang/src/step8_macros.erl index 07d0d5f9..13f7b0e1 100644 --- a/erlang/src/step8_macros.erl +++ b/erlang/src/step8_macros.erl @@ -18,7 +18,7 @@ main([]) -> init() -> Env = core:ns(), eval(read("(def! not (fn* (a) (if a false true)))"), Env), - eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env), + eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env), eval(read("(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)))))))"), Env), Env. diff --git a/erlang/src/step9_try.erl b/erlang/src/step9_try.erl index 8211f76b..1810843c 100644 --- a/erlang/src/step9_try.erl +++ b/erlang/src/step9_try.erl @@ -18,7 +18,7 @@ main([]) -> init() -> Env = core:ns(), eval(read("(def! not (fn* (a) (if a false true)))"), Env), - eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env), + eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env), eval(read("(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)))))))"), Env), Env. diff --git a/erlang/src/stepA_mal.erl b/erlang/src/stepA_mal.erl index d4668fe4..edf75247 100644 --- a/erlang/src/stepA_mal.erl +++ b/erlang/src/stepA_mal.erl @@ -20,7 +20,7 @@ init() -> Env = core:ns(), eval(read("(def! *host-language* \"Erlang\")"), Env), eval(read("(def! not (fn* (a) (if a false true)))"), Env), - eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env), + eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env), eval(read("(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)))))))"), Env), Env. diff --git a/es6/step6_file.mjs b/es6/step6_file.mjs index e3fc7bbb..83773034 100644 --- a/es6/step6_file.mjs +++ b/es6/step6_file.mjs @@ -84,7 +84,7 @@ env_set(repl_env, Symbol.for('*ARGV*'), []) // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))') -REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') if (process.argv.length > 2) { env_set(repl_env, Symbol.for('*ARGV*'), process.argv.slice(3)) diff --git a/es6/step7_quote.mjs b/es6/step7_quote.mjs index 2fea25cb..f0a6bdc7 100644 --- a/es6/step7_quote.mjs +++ b/es6/step7_quote.mjs @@ -107,7 +107,7 @@ env_set(repl_env, Symbol.for('*ARGV*'), []) // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))') -REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') if (process.argv.length > 2) { env_set(repl_env, Symbol.for('*ARGV*'), process.argv.slice(3)) diff --git a/es6/step8_macros.mjs b/es6/step8_macros.mjs index 45195158..73d9dbb8 100644 --- a/es6/step8_macros.mjs +++ b/es6/step8_macros.mjs @@ -126,7 +126,7 @@ env_set(repl_env, Symbol.for('*ARGV*'), []) // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))') -REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') 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 (process.argv.length > 2) { diff --git a/es6/step9_try.mjs b/es6/step9_try.mjs index 7cc6e962..03eed349 100644 --- a/es6/step9_try.mjs +++ b/es6/step9_try.mjs @@ -137,7 +137,7 @@ env_set(repl_env, Symbol.for('*ARGV*'), []) // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))') -REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') 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 (process.argv.length > 2) { diff --git a/es6/stepA_mal.mjs b/es6/stepA_mal.mjs index 4ae066d8..1ee2dc8f 100644 --- a/es6/stepA_mal.mjs +++ b/es6/stepA_mal.mjs @@ -138,7 +138,7 @@ env_set(repl_env, Symbol.for('*ARGV*'), []) // core.mal: defined using language itself REP('(def! *host-language* "ecmascript6")') REP('(def! not (fn* (a) (if a false true)))') -REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') 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 (process.argv.length > 2) { diff --git a/examples/clojurewest2014.mal b/examples/clojurewest2014.mal index 2d26336b..c88afe2d 100755 --- a/examples/clojurewest2014.mal +++ b/examples/clojurewest2014.mal @@ -124,4 +124,3 @@ (present (rest slides)))))) (present conj-slides) - diff --git a/examples/exercises.mal b/examples/exercises.mal index 51e59e39..5a0ba719 100644 --- a/examples/exercises.mal +++ b/examples/exercises.mal @@ -163,8 +163,3 @@ ;; ((compose f1 f2) x) is equivalent to (f1 (f2 x)) ;; This is the mathematical composition. For practical purposes, `->` ;; and `->>` defined in `core.mal` are more efficient and general. - -;; This `nil` is intentional so that the result of doing `load-file` is -;; `nil` instead of whatever happens to be the last definiton. -;; FIXME: can be removed after merge of load-file-trailing-new-line-nil -nil diff --git a/examples/presentation.mal b/examples/presentation.mal index 093f9faf..4e0c3383 100755 --- a/examples/presentation.mal +++ b/examples/presentation.mal @@ -120,4 +120,3 @@ (present (rest slides)))))) (present slides) - diff --git a/factor/step6_file/step6_file.factor b/factor/step6_file/step6_file.factor index 3db68408..9c0abe4b 100755 --- a/factor/step6_file/step6_file.factor +++ b/factor/step6_file/step6_file.factor @@ -106,7 +106,7 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at " (def! not (fn* (a) (if a false true))) -(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\"))))) +(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\"))))) " string-lines harvest [ REP drop ] each MAIN: main diff --git a/factor/step7_quote/step7_quote.factor b/factor/step7_quote/step7_quote.factor index 99264e8b..8ebe3b2c 100755 --- a/factor/step7_quote/step7_quote.factor +++ b/factor/step7_quote/step7_quote.factor @@ -121,7 +121,7 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at " (def! not (fn* (a) (if a false true))) -(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\"))))) +(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\"))))) " string-lines harvest [ REP drop ] each MAIN: main diff --git a/factor/step8_macros/step8_macros.factor b/factor/step8_macros/step8_macros.factor index 330ccb70..8a251e35 100755 --- a/factor/step8_macros/step8_macros.factor +++ b/factor/step8_macros/step8_macros.factor @@ -139,7 +139,7 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at " (def! not (fn* (a) (if a false true))) -(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\"))))) +(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\"))))) (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))))))) " string-lines harvest [ REP drop ] each diff --git a/factor/step9_try/step9_try.factor b/factor/step9_try/step9_try.factor index 1a596c89..877a3016 100755 --- a/factor/step9_try/step9_try.factor +++ b/factor/step9_try/step9_try.factor @@ -151,7 +151,7 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at " (def! not (fn* (a) (if a false true))) -(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\"))))) +(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\"))))) (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))))))) " string-lines harvest [ REP drop ] each diff --git a/factor/stepA_mal/stepA_mal.factor b/factor/stepA_mal/stepA_mal.factor index 25c91d8c..d95ee884 100755 --- a/factor/stepA_mal/stepA_mal.factor +++ b/factor/stepA_mal/stepA_mal.factor @@ -153,7 +153,7 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at " (def! *host-language* \"factor\") (def! not (fn* (a) (if a false true))) -(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\"))))) +(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\"))))) (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))))))) " string-lines harvest [ READ repl-env get EVAL drop ] each diff --git a/fantom/src/step6_file/fan/main.fan b/fantom/src/step6_file/fan/main.fan index aad03665..054164c4 100644 --- a/fantom/src/step6_file/fan/main.fan +++ b/fantom/src/step6_file/fan/main.fan @@ -101,7 +101,7 @@ class Main // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if (!args.isEmpty) { diff --git a/fantom/src/step7_quote/fan/main.fan b/fantom/src/step7_quote/fan/main.fan index 7158f033..a61976f3 100644 --- a/fantom/src/step7_quote/fan/main.fan +++ b/fantom/src/step7_quote/fan/main.fan @@ -122,7 +122,7 @@ class Main // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if (!args.isEmpty) { diff --git a/fantom/src/step8_macros/fan/main.fan b/fantom/src/step8_macros/fan/main.fan index 73310b1e..ab2d2bff 100644 --- a/fantom/src/step8_macros/fan/main.fan +++ b/fantom/src/step8_macros/fan/main.fan @@ -151,7 +151,7 @@ class Main // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if (!args.isEmpty) diff --git a/fantom/src/step9_try/fan/main.fan b/fantom/src/step9_try/fan/main.fan index b9f314df..58b29123 100644 --- a/fantom/src/step9_try/fan/main.fan +++ b/fantom/src/step9_try/fan/main.fan @@ -163,7 +163,7 @@ class Main // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if (!args.isEmpty) diff --git a/fantom/src/stepA_mal/fan/main.fan b/fantom/src/stepA_mal/fan/main.fan index 72587905..5b4c49a8 100644 --- a/fantom/src/stepA_mal/fan/main.fan +++ b/fantom/src/stepA_mal/fan/main.fan @@ -164,7 +164,7 @@ class Main // core.mal: defined using the language itself REP("(def! *host-language* \"fantom\")", repl_env) REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if (!args.isEmpty) diff --git a/forth/step6_file.fs b/forth/step6_file.fs index 649dd642..5f7e0dad 100644 --- a/forth/step6_file.fs +++ b/forth/step6_file.fs @@ -241,7 +241,7 @@ defcore swap! { argv argc -- val } new-val ;; s\" (def! not (fn* (x) (if x false true)))" rep 2drop -s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop +s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" rep 2drop : repl ( -- ) begin diff --git a/forth/step7_quote.fs b/forth/step7_quote.fs index dedefc7c..5286d503 100644 --- a/forth/step7_quote.fs +++ b/forth/step7_quote.fs @@ -283,7 +283,7 @@ defcore swap! { argv argc -- val } new-val ;; s\" (def! not (fn* (x) (if x false true)))" rep 2drop -s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop +s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" rep 2drop : repl ( -- ) begin diff --git a/forth/step8_macros.fs b/forth/step8_macros.fs index fffee717..202b3775 100644 --- a/forth/step8_macros.fs +++ b/forth/step8_macros.fs @@ -308,7 +308,7 @@ defcore swap! { argv argc -- val } new-val ;; s\" (def! not (fn* (x) (if x false true)))" rep 2drop -s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop +s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" rep 2drop s\" (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 2drop : repl ( -- ) diff --git a/forth/step9_try.fs b/forth/step9_try.fs index d30afadb..435392be 100644 --- a/forth/step9_try.fs +++ b/forth/step9_try.fs @@ -351,7 +351,7 @@ defcore map ( argv argc -- list ) here>MalList ;; s\" (def! not (fn* (x) (if x false true)))" rep 2drop -s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop +s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" rep 2drop s\" (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 2drop : repl ( -- ) diff --git a/forth/stepA_mal.fs b/forth/stepA_mal.fs index 28979483..0aa7e107 100644 --- a/forth/stepA_mal.fs +++ b/forth/stepA_mal.fs @@ -359,7 +359,7 @@ defcore map ( argv argc -- list ) s\" (def! *host-language* \"forth\")" rep 2drop s\" (def! not (fn* (x) (if x false true)))" rep 2drop -s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop +s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" rep 2drop s\" (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 2drop : repl ( -- ) diff --git a/fsharp/step6_file.fs b/fsharp/step6_file.fs index 1e03c55f..92f2072f 100644 --- a/fsharp/step6_file.fs +++ b/fsharp/step6_file.fs @@ -137,7 +137,7 @@ module REPL RE env """ (def! not (fn* (a) (if a false true))) - (def! load-file (fn* (f) (eval (read-string (slurp f))))) + (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """ |> Seq.iter ignore env diff --git a/fsharp/step7_quote.fs b/fsharp/step7_quote.fs index de6eb191..df0d09e2 100644 --- a/fsharp/step7_quote.fs +++ b/fsharp/step7_quote.fs @@ -157,7 +157,7 @@ module REPL RE env """ (def! not (fn* (a) (if a false true))) - (def! load-file (fn* (f) (eval (read-string (slurp f))))) + (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) """ |> Seq.iter ignore env diff --git a/fsharp/step8_macros.fs b/fsharp/step8_macros.fs index 644114b4..95dbf311 100644 --- a/fsharp/step8_macros.fs +++ b/fsharp/step8_macros.fs @@ -185,7 +185,7 @@ module REPL RE env """ (def! not (fn* (a) (if a false true))) - (def! load-file (fn* (f) (eval (read-string (slurp f))))) + (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) (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))))))) """ |> Seq.iter ignore diff --git a/fsharp/step9_try.fs b/fsharp/step9_try.fs index c001836b..a9883f7e 100644 --- a/fsharp/step9_try.fs +++ b/fsharp/step9_try.fs @@ -205,7 +205,7 @@ module REPL RE env """ (def! not (fn* (a) (if a false true))) - (def! load-file (fn* (f) (eval (read-string (slurp f))))) + (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) (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))))))) """ |> Seq.iter ignore diff --git a/fsharp/stepA_mal.fs b/fsharp/stepA_mal.fs index 621657b2..6960dae4 100644 --- a/fsharp/stepA_mal.fs +++ b/fsharp/stepA_mal.fs @@ -216,7 +216,7 @@ module REPL RE env """ (def! *host-language* "fsharp") (def! not (fn* (a) (if a false true))) - (def! load-file (fn* (f) (eval (read-string (slurp f))))) + (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) (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))))))) """ |> Seq.iter ignore diff --git a/gnu-smalltalk/step6_file.st b/gnu-smalltalk/step6_file.st index 9e79435f..237a88e7 100644 --- a/gnu-smalltalk/step6_file.st +++ b/gnu-smalltalk/step6_file.st @@ -172,7 +172,7 @@ replEnv set: #eval value: (Fn new: [ :args | MAL EVAL: args first env: replEnv ] replEnv set: #'*ARGV*' value: (MALList new: argv). MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv. -MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv. +MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))' env: replEnv. Smalltalk arguments notEmpty ifTrue: [ MAL rep: '(load-file "', Smalltalk arguments first, '")' env: replEnv diff --git a/gnu-smalltalk/step7_quote.st b/gnu-smalltalk/step7_quote.st index bdb8d88b..e779f684 100644 --- a/gnu-smalltalk/step7_quote.st +++ b/gnu-smalltalk/step7_quote.st @@ -216,7 +216,7 @@ replEnv set: #eval value: (Fn new: [ :args | MAL EVAL: args first env: replEnv ] replEnv set: #'*ARGV*' value: (MALList new: argv). MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv. -MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv. +MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))' env: replEnv. Smalltalk arguments notEmpty ifTrue: [ MAL rep: '(load-file "', Smalltalk arguments first, '")' env: replEnv diff --git a/gnu-smalltalk/step8_macros.st b/gnu-smalltalk/step8_macros.st index cd45f841..dcd06b93 100644 --- a/gnu-smalltalk/step8_macros.st +++ b/gnu-smalltalk/step8_macros.st @@ -269,7 +269,7 @@ replEnv set: #eval value: (Fn new: [ :args | MAL EVAL: args first env: replEnv ] replEnv set: #'*ARGV*' value: (MALList new: argv). MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv. -MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv. +MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))' env: replEnv. MAL 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)))))))' env: replEnv. Smalltalk arguments notEmpty ifTrue: [ diff --git a/gnu-smalltalk/step9_try.st b/gnu-smalltalk/step9_try.st index c5e22fcd..05b3f773 100644 --- a/gnu-smalltalk/step9_try.st +++ b/gnu-smalltalk/step9_try.st @@ -290,7 +290,7 @@ replEnv set: #eval value: (Fn new: [ :args | MAL EVAL: args first env: replEnv ] replEnv set: #'*ARGV*' value: (MALList new: argv). MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv. -MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv. +MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))' env: replEnv. MAL 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)))))))' env: replEnv. Smalltalk arguments notEmpty ifTrue: [ diff --git a/gnu-smalltalk/stepA_mal.st b/gnu-smalltalk/stepA_mal.st index 67dcd2de..6461c422 100644 --- a/gnu-smalltalk/stepA_mal.st +++ b/gnu-smalltalk/stepA_mal.st @@ -291,7 +291,7 @@ replEnv set: #'*ARGV*' value: (MALList new: argv). replEnv set: #'*host-language*' value: (MALString new: 'smalltalk'). MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv. -MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv. +MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))' env: replEnv. MAL 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)))))))' env: replEnv. Smalltalk arguments notEmpty ifTrue: [ diff --git a/go/src/step6_file/step6_file.go b/go/src/step6_file/step6_file.go index 1b78537c..74263c32 100644 --- a/go/src/step6_file/step6_file.go +++ b/go/src/step6_file/step6_file.go @@ -218,7 +218,7 @@ func main() { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") // called with mal script to load and eval if len(os.Args) > 1 { diff --git a/go/src/step7_quote/step7_quote.go b/go/src/step7_quote/step7_quote.go index 42aab4d2..a7502814 100644 --- a/go/src/step7_quote/step7_quote.go +++ b/go/src/step7_quote/step7_quote.go @@ -253,7 +253,7 @@ func main() { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") // called with mal script to load and eval if len(os.Args) > 1 { diff --git a/go/src/step8_macros/step8_macros.go b/go/src/step8_macros/step8_macros.go index 9a8ffa6d..902bf043 100644 --- a/go/src/step8_macros/step8_macros.go +++ b/go/src/step8_macros/step8_macros.go @@ -309,7 +309,7 @@ func main() { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") // called with mal script to load and eval diff --git a/go/src/step9_try/step9_try.go b/go/src/step9_try/step9_try.go index 52f939a0..0e3a9e43 100644 --- a/go/src/step9_try/step9_try.go +++ b/go/src/step9_try/step9_try.go @@ -337,7 +337,7 @@ func main() { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") // called with mal script to load and eval diff --git a/go/src/stepA_mal/stepA_mal.go b/go/src/stepA_mal/stepA_mal.go index 223f46d9..3b723d9c 100644 --- a/go/src/stepA_mal/stepA_mal.go +++ b/go/src/stepA_mal/stepA_mal.go @@ -338,7 +338,7 @@ func main() { // core.mal: defined using the language itself rep("(def! *host-language* \"go\")") rep("(def! not (fn* (a) (if a false true)))") - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") // called with mal script to load and eval diff --git a/groovy/step6_file.groovy b/groovy/step6_file.groovy index ebdae635..010f8d62 100644 --- a/groovy/step6_file.groovy +++ b/groovy/step6_file.groovy @@ -98,7 +98,7 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List) // core.mal: defined using mal itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if (this.args.size() > 0) { repl_env.set(new MalSymbol("*ARGV*"), this.args.drop(1) as List) diff --git a/groovy/step7_quote.groovy b/groovy/step7_quote.groovy index ee2e3394..d0f3c1c7 100644 --- a/groovy/step7_quote.groovy +++ b/groovy/step7_quote.groovy @@ -119,7 +119,7 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List) // core.mal: defined using mal itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if (this.args.size() > 0) { repl_env.set(new MalSymbol("*ARGV*"), this.args.drop(1) as List) diff --git a/groovy/step8_macros.groovy b/groovy/step8_macros.groovy index 8ede17d8..24da57fe 100644 --- a/groovy/step8_macros.groovy +++ b/groovy/step8_macros.groovy @@ -148,7 +148,7 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List) // core.mal: defined using mal itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))"); diff --git a/groovy/step9_try.groovy b/groovy/step9_try.groovy index bef6e2c7..2ee26264 100644 --- a/groovy/step9_try.groovy +++ b/groovy/step9_try.groovy @@ -166,7 +166,7 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List) // core.mal: defined using mal itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))"); diff --git a/groovy/stepA_mal.groovy b/groovy/stepA_mal.groovy index 8485e40c..2d137861 100644 --- a/groovy/stepA_mal.groovy +++ b/groovy/stepA_mal.groovy @@ -167,7 +167,7 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List) // core.mal: defined using mal itself REP("(def! *host-language* \"groovy\")") REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 (this.args.size() > 0) { diff --git a/guile/step6_file.scm b/guile/step6_file.scm index 3c34aff6..e95e8352 100644 --- a/guile/step6_file.scm +++ b/guile/step6_file.scm @@ -132,7 +132,7 @@ ((*toplevel* 'set) 'eval (make-func (lambda (ast) (EVAL ast *toplevel*)))) ((*toplevel* 'set) '*ARGV* '()) (EVAL-string "(def! not (fn* (x) (if x false true)))") -(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (let ((args (cdr (command-line)))) (cond diff --git a/guile/step7_quote.scm b/guile/step7_quote.scm index 0e50c31e..f6bcad53 100644 --- a/guile/step7_quote.scm +++ b/guile/step7_quote.scm @@ -141,7 +141,7 @@ ((*toplevel* 'set) 'eval (make-func (lambda (ast) (EVAL ast *toplevel*)))) ((*toplevel* 'set) '*ARGV* '()) (EVAL-string "(def! not (fn* (x) (if x false true)))") -(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (let ((args (cdr (command-line)))) (cond diff --git a/guile/step8_macros.scm b/guile/step8_macros.scm index 39c46895..6797acff 100644 --- a/guile/step8_macros.scm +++ b/guile/step8_macros.scm @@ -161,7 +161,7 @@ ((*toplevel* 'set) 'eval (make-func (lambda (ast) (EVAL ast *toplevel*)))) ((*toplevel* 'set) '*ARGV* '()) (EVAL-string "(def! not (fn* (x) (if x false true)))") -(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (EVAL-string "(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)))))))") (let ((args (cdr (command-line)))) diff --git a/guile/step9_try.scm b/guile/step9_try.scm index 5aec65b1..af4701aa 100644 --- a/guile/step9_try.scm +++ b/guile/step9_try.scm @@ -184,7 +184,7 @@ ((*toplevel* 'set) 'throw (make-func (lambda (val) (throw 'mal-error val)))) ((*toplevel* 'set) '*ARGV* '()) (EVAL-string "(def! not (fn* (x) (if x false true)))") -(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (EVAL-string "(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)))))))") (let ((args (cdr (command-line)))) diff --git a/guile/stepA_mal.scm b/guile/stepA_mal.scm index 894f1478..7131147e 100644 --- a/guile/stepA_mal.scm +++ b/guile/stepA_mal.scm @@ -181,7 +181,7 @@ ((*toplevel* 'set) 'throw (make-func (lambda (val) (throw 'mal-error val)))) ((*toplevel* 'set) '*ARGV* '()) (EVAL-string "(def! not (fn* (x) (if x false true)))") -(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (EVAL-string "(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)))))))") (EVAL-string "(def! *host-language* \"guile\")") diff --git a/haskell/step6_file.hs b/haskell/step6_file.hs index f989f6bd..99fc2426 100644 --- a/haskell/step6_file.hs +++ b/haskell/step6_file.hs @@ -149,7 +149,7 @@ main = do -- core.mal: defined using the language itself re repl_env "(def! not (fn* (a) (if a false true)))" - re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" + re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" case args of script : scriptArgs -> do diff --git a/haskell/step7_quote.hs b/haskell/step7_quote.hs index c6c44834..6a2ce900 100644 --- a/haskell/step7_quote.hs +++ b/haskell/step7_quote.hs @@ -174,7 +174,7 @@ main = do -- core.mal: defined using the language itself re repl_env "(def! not (fn* (a) (if a false true)))" - re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" + re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" case args of script : scriptArgs -> do diff --git a/haskell/step8_macros.hs b/haskell/step8_macros.hs index 411b4408..b42e09a4 100644 --- a/haskell/step8_macros.hs +++ b/haskell/step8_macros.hs @@ -200,7 +200,7 @@ main = do -- core.mal: defined using the language itself re repl_env "(def! not (fn* (a) (if a false true)))" - re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" + re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" re repl_env "(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)))))))" case args of diff --git a/haskell/step9_try.hs b/haskell/step9_try.hs index ab94c996..c2651dd5 100644 --- a/haskell/step9_try.hs +++ b/haskell/step9_try.hs @@ -211,7 +211,7 @@ main = do -- core.mal: defined using the language itself re repl_env "(def! not (fn* (a) (if a false true)))" - re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" + re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" re repl_env "(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)))))))" case args of diff --git a/haskell/stepA_mal.hs b/haskell/stepA_mal.hs index 04a44a8e..4b6ed5d5 100644 --- a/haskell/stepA_mal.hs +++ b/haskell/stepA_mal.hs @@ -212,7 +212,7 @@ main = do -- core.mal: defined using the language itself re repl_env "(def! *host-language* \"haskell\")" re repl_env "(def! not (fn* (a) (if a false true)))" - re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" + re repl_env "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" re repl_env "(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)))))))" case args of diff --git a/haxe/Step6_file.hx b/haxe/Step6_file.hx index 4e7856b5..1eb5288d 100644 --- a/haxe/Step6_file.hx +++ b/haxe/Step6_file.hx @@ -121,7 +121,7 @@ class Step6_file { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (cmdargs.length > 0) { rep('(load-file "${cmdargs[0]}")'); diff --git a/haxe/Step7_quote.hx b/haxe/Step7_quote.hx index 8cf7e45e..548dc172 100644 --- a/haxe/Step7_quote.hx +++ b/haxe/Step7_quote.hx @@ -154,7 +154,7 @@ class Step7_quote { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (cmdargs.length > 0) { rep('(load-file "${cmdargs[0]}")'); diff --git a/haxe/Step8_macros.hx b/haxe/Step8_macros.hx index 0f63a64a..3ff57433 100644 --- a/haxe/Step8_macros.hx +++ b/haxe/Step8_macros.hx @@ -190,7 +190,7 @@ class Step8_macros { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); diff --git a/haxe/Step9_try.hx b/haxe/Step9_try.hx index 13aa3208..ee7d7218 100644 --- a/haxe/Step9_try.hx +++ b/haxe/Step9_try.hx @@ -212,7 +212,7 @@ class Step9_try { // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); diff --git a/haxe/StepA_mal.hx b/haxe/StepA_mal.hx index 958efce1..6a07558f 100644 --- a/haxe/StepA_mal.hx +++ b/haxe/StepA_mal.hx @@ -213,7 +213,7 @@ class StepA_mal { // core.mal: defined using the language itself rep("(def! *host-language* \"haxe\")"); rep("(def! not (fn* (a) (if a false true)))"); - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); diff --git a/hy/step6_file.hy b/hy/step6_file.hy index 409297de..17eb4564 100755 --- a/hy/step6_file.hy +++ b/hy/step6_file.hy @@ -105,7 +105,7 @@ ;; core.mal: defined using the language itself (REP "(def! not (fn* [a] (if a false true)))") -(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (defmain [&rest args] (if (>= (len args) 2) diff --git a/hy/step7_quote.hy b/hy/step7_quote.hy index bd9ce05a..38ca94e2 100755 --- a/hy/step7_quote.hy +++ b/hy/step7_quote.hy @@ -129,7 +129,7 @@ ;; core.mal: defined using the language itself (REP "(def! not (fn* [a] (if a false true)))") -(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (defmain [&rest args] (if (>= (len args) 2) diff --git a/hy/step8_macros.hy b/hy/step8_macros.hy index 5089a201..2e202b32 100755 --- a/hy/step8_macros.hy +++ b/hy/step8_macros.hy @@ -157,7 +157,7 @@ ;; core.mal: defined using the language itself (REP "(def! not (fn* [a] (if a false true)))") -(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (defmain [&rest args] diff --git a/hy/step9_try.hy b/hy/step9_try.hy index de2c9348..6a078d23 100755 --- a/hy/step9_try.hy +++ b/hy/step9_try.hy @@ -169,7 +169,7 @@ ;; core.mal: defined using the language itself (REP "(def! not (fn* [a] (if a false true)))") -(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (defmain [&rest args] diff --git a/hy/stepA_mal.hy b/hy/stepA_mal.hy index 42cd81dd..00bfeca5 100755 --- a/hy/stepA_mal.hy +++ b/hy/stepA_mal.hy @@ -170,7 +170,7 @@ ;; core.mal: defined using the language itself (REP "(def! *host-language* \"Hy\")") (REP "(def! not (fn* [a] (if a false true)))") -(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (defmain [&rest args] diff --git a/io/step6_file.io b/io/step6_file.io index 3bdc6a7f..7f54d972 100644 --- a/io/step6_file.io +++ b/io/step6_file.io @@ -81,7 +81,7 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2))) // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") -RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if(System args size > 1, REP("(load-file \"" .. (System args at(1)) .. "\")") diff --git a/io/step7_quote.io b/io/step7_quote.io index 0a0c4aeb..4f756a35 100644 --- a/io/step7_quote.io +++ b/io/step7_quote.io @@ -99,7 +99,7 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2))) // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") -RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if(System args size > 1, REP("(load-file \"" .. (System args at(1)) .. "\")") diff --git a/io/step8_macros.io b/io/step8_macros.io index 5f90678d..7f4ccb28 100644 --- a/io/step8_macros.io +++ b/io/step8_macros.io @@ -124,7 +124,7 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2))) // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") -RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") if(System args size > 1, diff --git a/io/step9_try.io b/io/step9_try.io index ed286bc2..06941388 100644 --- a/io/step9_try.io +++ b/io/step9_try.io @@ -135,7 +135,7 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2))) // core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") -RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") if(System args size > 1, diff --git a/io/stepA_mal.io b/io/stepA_mal.io index c3ca0d80..70b042f4 100644 --- a/io/stepA_mal.io +++ b/io/stepA_mal.io @@ -136,7 +136,7 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2))) // core.mal: defined using the language itself RE("(def! *host-language* \"io\")") RE("(def! not (fn* (a) (if a false true)))") -RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") if(System args size > 1, diff --git a/java/src/main/java/mal/step6_file.java b/java/src/main/java/mal/step6_file.java index 19c4c1cd..bcaf764c 100644 --- a/java/src/main/java/mal/step6_file.java +++ b/java/src/main/java/mal/step6_file.java @@ -158,7 +158,7 @@ public class step6_file { // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); - RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); Integer fileIdx = 0; if (args.length > 0 && args[0].equals("--raw")) { diff --git a/java/src/main/java/mal/step7_quote.java b/java/src/main/java/mal/step7_quote.java index 9f9f8e4c..41400992 100644 --- a/java/src/main/java/mal/step7_quote.java +++ b/java/src/main/java/mal/step7_quote.java @@ -190,7 +190,7 @@ public class step7_quote { // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); - RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); Integer fileIdx = 0; if (args.length > 0 && args[0].equals("--raw")) { diff --git a/java/src/main/java/mal/step8_macros.java b/java/src/main/java/mal/step8_macros.java index 24d29208..5b319537 100644 --- a/java/src/main/java/mal/step8_macros.java +++ b/java/src/main/java/mal/step8_macros.java @@ -231,7 +231,7 @@ public class step8_macros { // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); - RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); RE(repl_env, "(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)))))))"); Integer fileIdx = 0; diff --git a/java/src/main/java/mal/step9_try.java b/java/src/main/java/mal/step9_try.java index ba45f9f9..bd5bec05 100644 --- a/java/src/main/java/mal/step9_try.java +++ b/java/src/main/java/mal/step9_try.java @@ -257,7 +257,7 @@ public class step9_try { // core.mal: defined using the language itself RE(repl_env, "(def! not (fn* (a) (if a false true)))"); - RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); RE(repl_env, "(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)))))))"); Integer fileIdx = 0; diff --git a/java/src/main/java/mal/stepA_mal.java b/java/src/main/java/mal/stepA_mal.java index bc964a69..6e5dc36a 100644 --- a/java/src/main/java/mal/stepA_mal.java +++ b/java/src/main/java/mal/stepA_mal.java @@ -258,7 +258,7 @@ public class stepA_mal { // core.mal: defined using the language itself RE(repl_env, "(def! *host-language* \"java\")"); RE(repl_env, "(def! not (fn* (a) (if a false true)))"); - RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); + RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); RE(repl_env, "(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)))))))"); Integer fileIdx = 0; diff --git a/js/step6_file.js b/js/step6_file.js index b166e7e1..962aceb1 100644 --- a/js/step6_file.js +++ b/js/step6_file.js @@ -107,7 +107,7 @@ repl_env.set(types._symbol('*ARGV*'), []); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (typeof process !== 'undefined' && process.argv.length > 2) { repl_env.set(types._symbol('*ARGV*'), process.argv.slice(3)); diff --git a/js/step7_quote.js b/js/step7_quote.js index 3b414f17..216273c8 100644 --- a/js/step7_quote.js +++ b/js/step7_quote.js @@ -132,7 +132,7 @@ repl_env.set(types._symbol('*ARGV*'), []); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (typeof process !== 'undefined' && process.argv.length > 2) { repl_env.set(types._symbol('*ARGV*'), process.argv.slice(3)); diff --git a/js/step8_macros.js b/js/step8_macros.js index fc090fe1..b5b975ff 100644 --- a/js/step8_macros.js +++ b/js/step8_macros.js @@ -158,7 +158,7 @@ repl_env.set(types._symbol('*ARGV*'), []); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 (typeof process !== 'undefined' && process.argv.length > 2) { diff --git a/js/step9_try.js b/js/step9_try.js index fc7c5f9d..08a853e4 100644 --- a/js/step9_try.js +++ b/js/step9_try.js @@ -169,7 +169,7 @@ repl_env.set(types._symbol('*ARGV*'), []); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 (typeof process !== 'undefined' && process.argv.length > 2) { diff --git a/js/stepA_mal.js b/js/stepA_mal.js index 622248c2..4e6e49d4 100644 --- a/js/stepA_mal.js +++ b/js/stepA_mal.js @@ -170,7 +170,7 @@ repl_env.set(types._symbol('*ARGV*'), []); // core.mal: defined using the language itself rep("(def! *host-language* \"javascript\")") rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 (typeof process !== 'undefined' && process.argv.length > 2) { diff --git a/julia/step6_file.jl b/julia/step6_file.jl index 83246ffb..5d251dd7 100755 --- a/julia/step6_file.jl +++ b/julia/step6_file.jl @@ -96,7 +96,7 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if length(ARGS) > 0 REP("(load-file \"$(ARGS[1])\")") diff --git a/julia/step7_quote.jl b/julia/step7_quote.jl index 79dd652d..91395bc2 100755 --- a/julia/step7_quote.jl +++ b/julia/step7_quote.jl @@ -117,7 +117,7 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if length(ARGS) > 0 REP("(load-file \"$(ARGS[1])\")") diff --git a/julia/step8_macros.jl b/julia/step8_macros.jl index db10a846..7ca18bde 100755 --- a/julia/step8_macros.jl +++ b/julia/step8_macros.jl @@ -143,7 +143,7 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") diff --git a/julia/step9_try.jl b/julia/step9_try.jl index 166b4e0e..26459b26 100755 --- a/julia/step9_try.jl +++ b/julia/step9_try.jl @@ -161,7 +161,7 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") diff --git a/julia/stepA_mal.jl b/julia/stepA_mal.jl index 32764a05..629c6980 100755 --- a/julia/stepA_mal.jl +++ b/julia/stepA_mal.jl @@ -162,7 +162,7 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) # core.mal: defined using the language itself REP("(def! *host-language* \"julia\")") REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") diff --git a/kotlin/src/mal/step6_file.kt b/kotlin/src/mal/step6_file.kt index bbb24a07..12baaaf3 100644 --- a/kotlin/src/mal/step6_file.kt +++ b/kotlin/src/mal/step6_file.kt @@ -89,7 +89,7 @@ fun main(args: Array) { repl_env.set(MalSymbol("eval"), MalFunction({ a: ISeq -> eval(a.first(), repl_env) })) rep("(def! not (fn* (a) (if a false true)))", repl_env) - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if (args.any()) { rep("(load-file \"${args[0]}\")", repl_env) diff --git a/kotlin/src/mal/step7_quote.kt b/kotlin/src/mal/step7_quote.kt index b8d4ab46..5b0d3d01 100644 --- a/kotlin/src/mal/step7_quote.kt +++ b/kotlin/src/mal/step7_quote.kt @@ -123,7 +123,7 @@ fun main(args: Array) { repl_env.set(MalSymbol("eval"), MalFunction({ a: ISeq -> eval(a.first(), repl_env) })) rep("(def! not (fn* (a) (if a false true)))", repl_env) - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if (args.any()) { rep("(load-file \"${args[0]}\")", repl_env) diff --git a/kotlin/src/mal/step8_macros.kt b/kotlin/src/mal/step8_macros.kt index 8d223c5d..59541e15 100644 --- a/kotlin/src/mal/step8_macros.kt +++ b/kotlin/src/mal/step8_macros.kt @@ -153,7 +153,7 @@ fun main(args: Array) { repl_env.set(MalSymbol("eval"), MalFunction({ a: ISeq -> eval(a.first(), repl_env) })) rep("(def! not (fn* (a) (if a false true)))", repl_env) - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if (args.any()) { diff --git a/kotlin/src/mal/step9_try.kt b/kotlin/src/mal/step9_try.kt index 722de183..98c4d34c 100644 --- a/kotlin/src/mal/step9_try.kt +++ b/kotlin/src/mal/step9_try.kt @@ -169,7 +169,7 @@ fun main(args: Array) { repl_env.set(MalSymbol("eval"), MalFunction({ a: ISeq -> eval(a.first(), repl_env) })) rep("(def! not (fn* (a) (if a false true)))", repl_env) - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if (args.any()) { diff --git a/kotlin/src/mal/stepA_mal.kt b/kotlin/src/mal/stepA_mal.kt index 93abe0fd..1b3170d4 100644 --- a/kotlin/src/mal/stepA_mal.kt +++ b/kotlin/src/mal/stepA_mal.kt @@ -170,7 +170,7 @@ fun main(args: Array) { repl_env.set(MalSymbol("eval"), MalFunction({ a: ISeq -> eval(a.first(), repl_env) })) rep("(def! not (fn* (a) (if a false true)))", repl_env) - rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if (args.any()) { diff --git a/lib/README.md b/lib/README.md index f40bf654..e04c6526 100644 --- a/lib/README.md +++ b/lib/README.md @@ -8,9 +8,6 @@ However, here are some guidelines. - Begin with an one-line ;; short description -- End with `nil`, so that the result of `load-file` is conveniently - short when loading manually and predictilbe for automatic testing - - Describe the restrictions on each parameter in comments. - Define private symbols in hidden environments when possible. If this diff --git a/lib/alias-hacks.mal b/lib/alias-hacks.mal index 3583c7d3..5d2ac873 100644 --- a/lib/alias-hacks.mal +++ b/lib/alias-hacks.mal @@ -1,6 +1,6 @@ ;; aliases for common clojure names to mal builtins ;; NOTE: this is a hack -;; + ;; Origin: https://github.com/chr15m/frock ; TODO: re-implement as actually useful macros: @@ -20,5 +20,3 @@ (def! partial (fn* [pfn & args] (fn* [& args-inner] (apply pfn (concat args args-inner))))) - -nil diff --git a/lib/equality.mal b/lib/equality.mal index 5f4adaa9..90ca5287 100644 --- a/lib/equality.mal +++ b/lib/equality.mal @@ -75,5 +75,3 @@ (do (def! = mal-equal?) (println "equality.mal: Replaced = with pure mal implementation"))) - -nil diff --git a/lib/load-file-once.mal b/lib/load-file-once.mal index 0c0967b4..2d7ac0c1 100644 --- a/lib/load-file-once.mal +++ b/lib/load-file-once.mal @@ -14,5 +14,3 @@ (do (swap! seen assoc filename nil) (load-file filename)))))))) - -nil diff --git a/lib/memoize.mal b/lib/memoize.mal index 63e4a72d..ca3a4795 100644 --- a/lib/memoize.mal +++ b/lib/memoize.mal @@ -23,5 +23,3 @@ (do (swap! mem assoc key ret) ret)))))))) - -nil diff --git a/lib/perf.mal b/lib/perf.mal index 9867b7c0..32a3189f 100644 --- a/lib/perf.mal +++ b/lib/perf.mal @@ -39,5 +39,3 @@ (run-fn-for* fn 1000 0 0) ;; Now do the test (run-fn-for* fn (* 1000 max-secs) 0 0))))) - -nil diff --git a/lib/pprint.mal b/lib/pprint.mal index c0cdc15f..c5be941c 100644 --- a/lib/pprint.mal +++ b/lib/pprint.mal @@ -41,5 +41,3 @@ (fn* [obj] (println (pp- obj 0))))) - -nil diff --git a/lib/protocols.mal b/lib/protocols.mal index cbfbb05a..4bd8b80b 100644 --- a/lib/protocols.mal +++ b/lib/protocols.mal @@ -93,5 +93,3 @@ ;; then `(method1 obj)` and `(method2 obj 1 2)` ;; dispatch to the concrete implementation provided by the exact type. ;; Should the type evolve, the calling code needs not change. - -nil diff --git a/lib/reducers.mal b/lib/reducers.mal index 943a325c..f8e6dc7f 100644 --- a/lib/reducers.mal +++ b/lib/reducers.mal @@ -30,5 +30,3 @@ ;; xs : sequence of Elements x1 x2 .. xn ;; return : Accumulator (rec f xs init (- (count xs) 1))))) - -nil diff --git a/lib/test_cascade.mal b/lib/test_cascade.mal index 680206a9..d2d81e77 100644 --- a/lib/test_cascade.mal +++ b/lib/test_cascade.mal @@ -65,5 +65,3 @@ true (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar (and ~@(rest xs)) ~condvar)))))) - -nil diff --git a/lib/threading.mal b/lib/threading.mal index a9d60e60..36bf468f 100644 --- a/lib/threading.mal +++ b/lib/threading.mal @@ -32,5 +32,3 @@ (if (list? form) `(~(first form) ~@(rest form) ~acc) (list form acc)))) - -nil diff --git a/lib/trivial.mal b/lib/trivial.mal index 209693fd..aa216910 100644 --- a/lib/trivial.mal +++ b/lib/trivial.mal @@ -18,5 +18,3 @@ (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc)))))) - -nil diff --git a/livescript/step6_file.ls b/livescript/step6_file.ls index 1e96b9ab..fac53c29 100644 --- a/livescript/step6_file.ls +++ b/livescript/step6_file.ls @@ -218,7 +218,7 @@ rep ' (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))' + (str "(do " (slurp f) "\nnil)")))))' # Parse program arguments. # The first two (exe and core-file) are, respectively, diff --git a/livescript/step7_quote.ls b/livescript/step7_quote.ls index a2007c08..9e474055 100644 --- a/livescript/step7_quote.ls +++ b/livescript/step7_quote.ls @@ -259,7 +259,7 @@ rep ' (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))' + (str "(do " (slurp f) "\nnil)")))))' # Parse program arguments. # The first two (exe and core-file) are, respectively, diff --git a/livescript/step8_macros.ls b/livescript/step8_macros.ls index b5ac5706..f92c07b5 100644 --- a/livescript/step8_macros.ls +++ b/livescript/step8_macros.ls @@ -308,7 +308,7 @@ rep ' (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))' + (str "(do " (slurp f) "\nnil)")))))' # Define cond. rep ' diff --git a/livescript/step9_try.ls b/livescript/step9_try.ls index abd3b8ec..377c3a6b 100644 --- a/livescript/step9_try.ls +++ b/livescript/step9_try.ls @@ -339,7 +339,7 @@ rep ' (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))' + (str "(do " (slurp f) "\nnil)")))))' # Define cond. rep ' diff --git a/livescript/stepA_mal.ls b/livescript/stepA_mal.ls index 08fbd81e..f8808d12 100644 --- a/livescript/stepA_mal.ls +++ b/livescript/stepA_mal.ls @@ -339,7 +339,7 @@ rep ' (fn* (f) (eval (read-string - (str "(do " (slurp f) ")")))))' + (str "(do " (slurp f) "\nnil)")))))' # Define cond. rep ' diff --git a/logo/step6_file.lg b/logo/step6_file.lg index 2bf753ea..ef51812e 100644 --- a/logo/step6_file.lg +++ b/logo/step6_file.lg @@ -139,7 +139,7 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ; core.mal: defined using the language itself ignore re "|(def! not (fn* (a) (if a false true)))| -ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| +ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))| if not emptyp :command.line [ catch "error [ignore re (word "\(load-file :space_char "\" first :command.line "\"\) )] diff --git a/logo/step7_quote.lg b/logo/step7_quote.lg index 5a29b7f5..43bf939f 100644 --- a/logo/step7_quote.lg +++ b/logo/step7_quote.lg @@ -166,7 +166,7 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ; core.mal: defined using the language itself ignore re "|(def! not (fn* (a) (if a false true)))| -ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| +ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))| if not emptyp :command.line [ catch "error [ignore re (word "\(load-file :space_char "\" first :command.line "\"\) )] diff --git a/logo/step8_macros.lg b/logo/step8_macros.lg index d45eb827..c08ff659 100644 --- a/logo/step8_macros.lg +++ b/logo/step8_macros.lg @@ -199,7 +199,7 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ; core.mal: defined using the language itself ignore re "|(def! not (fn* (a) (if a false true)))| -ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| +ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))| ignore 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)))))))| if not emptyp :command.line [ diff --git a/logo/step9_try.lg b/logo/step9_try.lg index ac02d269..0dfb8fbe 100644 --- a/logo/step9_try.lg +++ b/logo/step9_try.lg @@ -218,7 +218,7 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ; core.mal: defined using the language itself ignore re "|(def! not (fn* (a) (if a false true)))| -ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| +ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))| ignore 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)))))))| if not emptyp :command.line [ diff --git a/logo/stepA_mal.lg b/logo/stepA_mal.lg index 6c842fbe..4af301c7 100644 --- a/logo/stepA_mal.lg +++ b/logo/stepA_mal.lg @@ -219,7 +219,7 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ; core.mal: defined using the language itself ignore re "|(def! *host-language* "logo")| ignore re "|(def! not (fn* (a) (if a false true)))| -ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| +ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))| ignore 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)))))))| if not emptyp :command.line [ diff --git a/lua/step6_file.lua b/lua/step6_file.lua index 4a27a24a..c042237e 100755 --- a/lua/step6_file.lua +++ b/lua/step6_file.lua @@ -100,7 +100,7 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) -- core.mal: defined using mal rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if #arg > 0 and arg[1] == "--raw" then readline.raw = true diff --git a/lua/step7_quote.lua b/lua/step7_quote.lua index d014cc73..30d5cb7a 100755 --- a/lua/step7_quote.lua +++ b/lua/step7_quote.lua @@ -126,7 +126,7 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) -- core.mal: defined using mal rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if #arg > 0 and arg[1] == "--raw" then readline.raw = true diff --git a/lua/step8_macros.lua b/lua/step8_macros.lua index cb49946b..4265658a 100755 --- a/lua/step8_macros.lua +++ b/lua/step8_macros.lua @@ -153,7 +153,7 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) -- core.mal: defined using mal rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 #arg > 0 and arg[1] == "--raw" then diff --git a/lua/step9_try.lua b/lua/step9_try.lua index b9620bfb..a1e55c07 100755 --- a/lua/step9_try.lua +++ b/lua/step9_try.lua @@ -171,7 +171,7 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) -- core.mal: defined using mal rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") function print_exception(exc) diff --git a/lua/stepA_mal.lua b/lua/stepA_mal.lua index 47c35ca8..302e359b 100755 --- a/lua/stepA_mal.lua +++ b/lua/stepA_mal.lua @@ -173,7 +173,7 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) -- core.mal: defined using mal rep("(def! *host-language* \"lua\")") rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") function print_exception(exc) diff --git a/make/step6_file.mk b/make/step6_file.mk index a8555dfa..f851747e 100644 --- a/make/step6_file.mk +++ b/make/step6_file.mk @@ -114,7 +114,7 @@ REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv)) # core.mal: defined in terms of the language itself $(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, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) )) # Load and eval any files specified on the command line $(if $(MAKECMDGOALS),\ diff --git a/make/step7_quote.mk b/make/step7_quote.mk index d1f6bca1..ba961832 100644 --- a/make/step7_quote.mk +++ b/make/step7_quote.mk @@ -131,7 +131,7 @@ REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv)) # core.mal: defined in terms of the language itself $(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, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) )) # Load and eval any files specified on the command line $(if $(MAKECMDGOALS),\ diff --git a/make/step8_macros.mk b/make/step8_macros.mk index 310d6fda..ed0cd6fb 100644 --- a/make/step8_macros.mk +++ b/make/step8_macros.mk @@ -154,7 +154,7 @@ REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv)) # core.mal: defined in terms of the language itself $(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, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) )) $(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))))))) )) # Load and eval any files specified on the command line diff --git a/make/step9_try.mk b/make/step9_try.mk index 46a292dc..a179d8c4 100644 --- a/make/step9_try.mk +++ b/make/step9_try.mk @@ -169,7 +169,7 @@ REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv)) # core.mal: defined in terms of the language itself $(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, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) )) $(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))))))) )) # Load and eval any files specified on the command line diff --git a/make/stepA_mal.mk b/make/stepA_mal.mk index 22840993..c3bbd1c3 100644 --- a/make/stepA_mal.mk +++ b/make/stepA_mal.mk @@ -174,7 +174,7 @@ 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, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)"))))) )) $(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))))))) )) # Load and eval any files specified on the command line diff --git a/mal/step6_file.mal b/mal/step6_file.mal index fbfeb897..5d9f193d 100644 --- a/mal/step6_file.mal +++ b/mal/step6_file.mal @@ -79,7 +79,7 @@ ;; core.mal: defined using the new language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") ;; repl loop (def! repl-loop (fn* [line] diff --git a/mal/step7_quote.mal b/mal/step7_quote.mal index 483898b6..d5187967 100644 --- a/mal/step7_quote.mal +++ b/mal/step7_quote.mal @@ -103,7 +103,7 @@ ;; core.mal: defined using the new language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") ;; repl loop (def! repl-loop (fn* [line] diff --git a/mal/step8_macros.mal b/mal/step8_macros.mal index 0018d4c7..d109f06f 100644 --- a/mal/step8_macros.mal +++ b/mal/step8_macros.mal @@ -125,7 +125,7 @@ ;; core.mal: defined using the new language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ;; repl loop diff --git a/mal/step9_try.mal b/mal/step9_try.mal index 676e93e7..89d697af 100644 --- a/mal/step9_try.mal +++ b/mal/step9_try.mal @@ -134,7 +134,7 @@ ;; core.mal: defined using the new language itself (rep "(def! not (fn* [a] (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ;; repl loop diff --git a/mal/stepA_mal.mal b/mal/stepA_mal.mal index 26feecf2..35db404c 100644 --- a/mal/stepA_mal.mal +++ b/mal/stepA_mal.mal @@ -135,7 +135,7 @@ ;; 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 "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ;; repl loop diff --git a/matlab/step6_file.m b/matlab/step6_file.m index 3e64a6a9..0ca356e6 100644 --- a/matlab/step6_file.m +++ b/matlab/step6_file.m @@ -122,7 +122,7 @@ function main(args) % core.mal: defined using the langauge itself rep('(def! not (fn* (a) (if a false true)))', repl_env); - rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env); + rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))"', repl_env); if ~isempty(args) rep(sprintf('(load-file "%s")', args{1}), repl_env); diff --git a/matlab/step7_quote.m b/matlab/step7_quote.m index 6f4577b4..63c7a453 100644 --- a/matlab/step7_quote.m +++ b/matlab/step7_quote.m @@ -150,7 +150,7 @@ function main(args) % core.mal: defined using the langauge itself rep('(def! not (fn* (a) (if a false true)))', repl_env); - rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env); + rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))"', repl_env); if ~isempty(args) rep(sprintf('(load-file "%s")', args{1}), repl_env); diff --git a/matlab/step8_macros.m b/matlab/step8_macros.m index db638262..d16519e0 100644 --- a/matlab/step8_macros.m +++ b/matlab/step8_macros.m @@ -182,7 +182,7 @@ function main(args) % core.mal: defined using the langauge itself rep('(def! not (fn* (a) (if a false true)))', repl_env); - rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env); + rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))"', repl_env); 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)))))))', repl_env); if ~isempty(args) diff --git a/matlab/step9_try.m b/matlab/step9_try.m index a24d2a5d..a640ec97 100644 --- a/matlab/step9_try.m +++ b/matlab/step9_try.m @@ -206,7 +206,7 @@ function main(args) % core.mal: defined using the langauge itself rep('(def! not (fn* (a) (if a false true)))', repl_env); - rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env); + rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))"', repl_env); 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)))))))', repl_env); if ~isempty(args) diff --git a/matlab/stepA_mal.m b/matlab/stepA_mal.m index a882cfad..09f25257 100644 --- a/matlab/stepA_mal.m +++ b/matlab/stepA_mal.m @@ -207,7 +207,7 @@ function main(args) % core.mal: defined using the langauge itself rep('(def! *host-language* "matlab")', repl_env); rep('(def! not (fn* (a) (if a false true)))', repl_env); - rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env); + rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))"', repl_env); 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)))))))', repl_env); if ~isempty(args) diff --git a/miniMAL/step6_file.json b/miniMAL/step6_file.json index 27f41553..366768f2 100644 --- a/miniMAL/step6_file.json +++ b/miniMAL/step6_file.json @@ -101,7 +101,7 @@ ["`", "core.mal: defined using mal itself"], ["rep", ["`", "(def! not (fn* (a) (if a false true)))"]], -["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]], +["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]], ["if", ["not", ["empty?", "ARGS"]], ["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]], diff --git a/miniMAL/step7_quote.json b/miniMAL/step7_quote.json index b4d6aabd..f5cd83c2 100644 --- a/miniMAL/step7_quote.json +++ b/miniMAL/step7_quote.json @@ -126,7 +126,7 @@ ["`", "core.mal: defined using mal itself"], ["rep", ["`", "(def! not (fn* (a) (if a false true)))"]], -["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]], +["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]], ["if", ["not", ["empty?", "ARGS"]], ["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]], diff --git a/miniMAL/step8_macros.json b/miniMAL/step8_macros.json index 418806d1..77d8bccc 100644 --- a/miniMAL/step8_macros.json +++ b/miniMAL/step8_macros.json @@ -150,7 +150,7 @@ ["`", "core.mal: defined using mal itself"], ["rep", ["`", "(def! not (fn* (a) (if a false true)))"]], -["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]], +["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]], ["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", ["not", ["empty?", "ARGS"]], diff --git a/miniMAL/step9_try.json b/miniMAL/step9_try.json index c57a1868..756c7eee 100644 --- a/miniMAL/step9_try.json +++ b/miniMAL/step9_try.json @@ -163,7 +163,7 @@ ["`", "core.mal: defined using mal itself"], ["rep", ["`", "(def! not (fn* (a) (if a false true)))"]], -["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]], +["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]], ["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", ["not", ["empty?", "ARGS"]], diff --git a/miniMAL/stepA_mal.json b/miniMAL/stepA_mal.json index f7028535..97ebe6f7 100644 --- a/miniMAL/stepA_mal.json +++ b/miniMAL/stepA_mal.json @@ -164,7 +164,7 @@ ["`", "core.mal: defined using mal itself"], ["rep", ["`", "(def! *host-language* \"miniMAL\")"]], ["rep", ["`", "(def! not (fn* (a) (if a false true)))"]], -["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]], +["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]], ["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", ["not", ["empty?", "ARGS"]], diff --git a/nasm/step6_file.asm b/nasm/step6_file.asm index 1c143640..98f4e0d5 100644 --- a/nasm/step6_file.asm +++ b/nasm/step6_file.asm @@ -61,7 +61,7 @@ section .data ;; Startup string. This is evaluated on startup static mal_startup_string, db "(do \ (def! not (fn* (a) (if a false true))) \ -(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ +(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,10,"nil)",34," ))))) \ )" ;; Command to run, appending the name of the script to run diff --git a/nasm/step7_quote.asm b/nasm/step7_quote.asm index 713e5675..621570cb 100644 --- a/nasm/step7_quote.asm +++ b/nasm/step7_quote.asm @@ -68,7 +68,7 @@ section .data ;; Startup string. This is evaluated on startup static mal_startup_string, db "(do \ (def! not (fn* (a) (if a false true))) \ -(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ +(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,10,"nil)",34," ))))) \ )" ;; Command to run, appending the name of the script to run diff --git a/nasm/step8_macros.asm b/nasm/step8_macros.asm index 06bc9167..9c46a0f0 100644 --- a/nasm/step8_macros.asm +++ b/nasm/step8_macros.asm @@ -72,7 +72,7 @@ section .data ;; Startup string. This is evaluated on startup static mal_startup_string, db "(do \ (def! not (fn* (a) (if a false true))) \ -(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ +(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,10,"nil)",34," ))))) \ (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ",34,"odd number of forms to cond",34,")) (cons 'cond (rest (rest xs))))))) \ )" diff --git a/nasm/step9_try.asm b/nasm/step9_try.asm index a92b03e5..64b17645 100644 --- a/nasm/step9_try.asm +++ b/nasm/step9_try.asm @@ -78,7 +78,7 @@ section .data ;; Startup string. This is evaluated on startup static mal_startup_string, db "(do \ (def! not (fn* (a) (if a false true))) \ -(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ +(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,10,"nil)",34," ))))) \ (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ",34,"odd number of forms to cond",34,")) (cons 'cond (rest (rest xs))))))) \ )" diff --git a/nasm/stepA_mal.asm b/nasm/stepA_mal.asm index 4cdf8236..8b5e910a 100644 --- a/nasm/stepA_mal.asm +++ b/nasm/stepA_mal.asm @@ -78,7 +78,7 @@ section .data ;; Startup string. This is evaluated on startup static mal_startup_string, db "(do \ (def! not (fn* (a) (if a false true))) \ -(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ +(def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,10,"nil)",34," ))))) \ (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ",34,"odd number of forms to cond",34,")) (cons 'cond (rest (rest xs))))))) \ (def! *host-language* ",34,"nasm",34,")\ (def! conj nil)\ diff --git a/nim/step6_file.nim b/nim/step6_file.nim index 7af6e6e1..c045af23 100644 --- a/nim/step6_file.nim +++ b/nim/step6_file.nim @@ -111,7 +111,7 @@ proc rep(str: string): string {.discardable.} = # core.mal: defined using mal itself rep "(def! not (fn* (a) (if a false true)))" -rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" if paramCount() >= 1: rep "(load-file \"" & paramStr(1) & "\")" diff --git a/nim/step7_quote.nim b/nim/step7_quote.nim index 341072c7..617db0f5 100644 --- a/nim/step7_quote.nim +++ b/nim/step7_quote.nim @@ -132,7 +132,7 @@ proc rep(str: string): string {.discardable.} = # core.mal: defined using mal itself rep "(def! not (fn* (a) (if a false true)))" -rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" if paramCount() >= 1: rep "(load-file \"" & paramStr(1) & "\")" diff --git a/nim/step8_macros.nim b/nim/step8_macros.nim index 0e22bd70..fd659f48 100644 --- a/nim/step8_macros.nim +++ b/nim/step8_macros.nim @@ -153,7 +153,7 @@ proc rep(str: string): string {.discardable.} = # core.mal: defined using mal itself rep "(def! not (fn* (a) (if a false true)))" -rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" 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 paramCount() >= 1: diff --git a/nim/step9_try.nim b/nim/step9_try.nim index f32d8d51..6c58f83e 100644 --- a/nim/step9_try.nim +++ b/nim/step9_try.nim @@ -172,7 +172,7 @@ proc rep(str: string): string {.discardable.} = # core.mal: defined using mal itself rep "(def! not (fn* (a) (if a false true)))" -rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" 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 paramCount() >= 1: diff --git a/nim/stepA_mal.nim b/nim/stepA_mal.nim index bf47e2ee..706eedee 100644 --- a/nim/stepA_mal.nim +++ b/nim/stepA_mal.nim @@ -172,7 +172,7 @@ proc rep(str: string): string {.discardable.} = # core.mal: defined using mal itself rep "(def! not (fn* (a) (if a false true)))" -rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" +rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" 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 "(def! *host-language* \"nim\")" diff --git a/objc/step6_file.m b/objc/step6_file.m index 0c8c421f..eee91c1e 100644 --- a/objc/step6_file.m +++ b/objc/step6_file.m @@ -137,7 +137,7 @@ int main () { // core.mal: defined using the language itself REP(@"(def! not (fn* (a) (if a false true)))", repl_env); - REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); if ([args count] > 1) { @try { diff --git a/objc/step7_quote.m b/objc/step7_quote.m index 34ef83bb..d2b04eb3 100644 --- a/objc/step7_quote.m +++ b/objc/step7_quote.m @@ -171,7 +171,7 @@ int main () { // core.mal: defined using the language itself REP(@"(def! not (fn* (a) (if a false true)))", repl_env); - REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); if ([args count] > 1) { @try { diff --git a/objc/step8_macros.m b/objc/step8_macros.m index 00e138c6..188f01ce 100644 --- a/objc/step8_macros.m +++ b/objc/step8_macros.m @@ -204,7 +204,7 @@ int main () { // core.mal: defined using the language itself REP(@"(def! not (fn* (a) (if a false true)))", repl_env); - REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); 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)))))))", repl_env); diff --git a/objc/step9_try.m b/objc/step9_try.m index 5b4d278c..45c9c92a 100644 --- a/objc/step9_try.m +++ b/objc/step9_try.m @@ -223,7 +223,7 @@ int main () { // core.mal: defined using the language itself REP(@"(def! not (fn* (a) (if a false true)))", repl_env); - REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); 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)))))))", repl_env); diff --git a/objc/stepA_mal.m b/objc/stepA_mal.m index fe21e1ca..4727e4f0 100644 --- a/objc/stepA_mal.m +++ b/objc/stepA_mal.m @@ -224,7 +224,7 @@ int main () { // core.mal: defined using the language itself REP(@"(def! *host-language* \"Objective-C\")", repl_env); REP(@"(def! not (fn* (a) (if a false true)))", repl_env); - REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env); + REP(@"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env); 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)))))))", repl_env); diff --git a/objpascal/step6_file.pas b/objpascal/step6_file.pas index d4d3324d..dfc53f16 100644 --- a/objpascal/step6_file.pas +++ b/objpascal/step6_file.pas @@ -195,7 +195,7 @@ begin // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))'); - REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); if ParamCount >= 1 then begin diff --git a/objpascal/step7_quote.pas b/objpascal/step7_quote.pas index 2455b1da..fc583b80 100644 --- a/objpascal/step7_quote.pas +++ b/objpascal/step7_quote.pas @@ -236,7 +236,7 @@ begin // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))'); - REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); if ParamCount >= 1 then begin diff --git a/objpascal/step8_macros.pas b/objpascal/step8_macros.pas index e814663e..541f2674 100644 --- a/objpascal/step8_macros.pas +++ b/objpascal/step8_macros.pas @@ -289,7 +289,7 @@ begin // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))'); - REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); 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)))))))'); diff --git a/objpascal/step9_try.pas b/objpascal/step9_try.pas index c93dbef4..0793afc4 100644 --- a/objpascal/step9_try.pas +++ b/objpascal/step9_try.pas @@ -311,7 +311,7 @@ begin // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))'); - REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); 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)))))))'); diff --git a/objpascal/stepA_mal.pas b/objpascal/stepA_mal.pas index f71b8fa7..94c7363d 100644 --- a/objpascal/stepA_mal.pas +++ b/objpascal/stepA_mal.pas @@ -313,7 +313,7 @@ begin // core.mal: defined using language itself REP('(def! not (fn* (a) (if a false true)))'); - REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); 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)))))))'); diff --git a/ocaml/step6_file.ml b/ocaml/step6_file.ml index 07df7c4f..625fd9cd 100644 --- a/ocaml/step6_file.ml +++ b/ocaml/step6_file.ml @@ -76,7 +76,7 @@ let rec main = else [])); Env.set repl_env (Types.symbol "eval") (Types.fn (function [ast] -> eval ast repl_env | _ -> T.Nil)); - ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); + ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); if Array.length Sys.argv > 1 then diff --git a/ocaml/step7_quote.ml b/ocaml/step7_quote.ml index e855133e..8598a2df 100644 --- a/ocaml/step7_quote.ml +++ b/ocaml/step7_quote.ml @@ -91,7 +91,7 @@ let rec main = else [])); Env.set repl_env (Types.symbol "eval") (Types.fn (function [ast] -> eval ast repl_env | _ -> T.Nil)); - ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); + ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); if Array.length Sys.argv > 1 then diff --git a/ocaml/step8_macros.ml b/ocaml/step8_macros.ml index 8b24abff..2bec4e26 100644 --- a/ocaml/step8_macros.ml +++ b/ocaml/step8_macros.ml @@ -119,7 +119,7 @@ let rec main = Env.set repl_env (Types.symbol "eval") (Types.fn (function [ast] -> eval ast repl_env | _ -> T.Nil)); - ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); + ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); ignore (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)))))))" repl_env); diff --git a/ocaml/step9_try.ml b/ocaml/step9_try.ml index 7557d82a..f95d8c5a 100644 --- a/ocaml/step9_try.ml +++ b/ocaml/step9_try.ml @@ -133,7 +133,7 @@ let rec main = Env.set repl_env (Types.symbol "eval") (Types.fn (function [ast] -> eval ast repl_env | _ -> T.Nil)); - ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); + ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); ignore (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)))))))" repl_env); diff --git a/ocaml/stepA_mal.ml b/ocaml/stepA_mal.ml index 41624214..e89efc43 100644 --- a/ocaml/stepA_mal.ml +++ b/ocaml/stepA_mal.ml @@ -134,7 +134,7 @@ let rec main = (Types.fn (function [ast] -> eval ast repl_env | _ -> T.Nil)); ignore (rep "(def! *host-language* \"ocaml\")" repl_env); - ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); + ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); ignore (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)))))))" repl_env); diff --git a/perl/step6_file.pl b/perl/step6_file.pl index 15498dff..1d68b6f5 100644 --- a/perl/step6_file.pl +++ b/perl/step6_file.pl @@ -125,7 +125,7 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_argv)); # core.mal: defined using the language itself REP(q[(def! not (fn* (a) (if a false true)))]); -REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))]); +REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))]); if (@ARGV && $ARGV[0] eq "--raw") { set_rl_mode("raw"); diff --git a/perl/step7_quote.pl b/perl/step7_quote.pl index d5025ae8..f25d23c5 100644 --- a/perl/step7_quote.pl +++ b/perl/step7_quote.pl @@ -155,7 +155,7 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_argv)); # core.mal: defined using the language itself REP(q[(def! not (fn* (a) (if a false true)))]); -REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))]); +REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))]); if (@ARGV && $ARGV[0] eq "--raw") { set_rl_mode("raw"); diff --git a/perl/step8_macros.pl b/perl/step8_macros.pl index f8d31c36..f7d890aa 100644 --- a/perl/step8_macros.pl +++ b/perl/step8_macros.pl @@ -193,10 +193,9 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_argv)); # core.mal: defined using the language itself REP(q[(def! not (fn* (a) (if a false true)))]); -REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))]); +REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))]); REP(q[(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 (@ARGV && $ARGV[0] eq "--raw") { set_rl_mode("raw"); shift @ARGV; diff --git a/perl/step9_try.pl b/perl/step9_try.pl index b8f58acb..945439ce 100644 --- a/perl/step9_try.pl +++ b/perl/step9_try.pl @@ -221,10 +221,9 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_argv)); # core.mal: defined using the language itself REP(q[(def! not (fn* (a) (if a false true)))]); -REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))]); +REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))]); REP(q[(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 (@ARGV && $ARGV[0] eq "--raw") { set_rl_mode("raw"); shift @ARGV; diff --git a/perl/stepA_mal.pl b/perl/stepA_mal.pl index aafe6e14..252b0a50 100644 --- a/perl/stepA_mal.pl +++ b/perl/stepA_mal.pl @@ -225,7 +225,7 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_argv)); # core.mal: defined using the language itself REP(q[(def! *host-language* "perl")]); REP(q[(def! not (fn* (a) (if a false true)))]); -REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))]); +REP(q[(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))]); REP(q[(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 (@ARGV && $ARGV[0] eq "--raw") { diff --git a/perl6/step6_file.pl b/perl6/step6_file.pl index 7a9c198a..8d97c175 100644 --- a/perl6/step6_file.pl +++ b/perl6/step6_file.pl @@ -83,7 +83,7 @@ sub MAIN ($source_file?, *@args) { $repl_env.set('eval', MalCode({ eval($^a, $repl_env) })); $repl_env.set('*ARGV*', MalList([@args.map({ MalString($_) })])); rep(q{(def! not (fn* (a) (if a false true)))}); - rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); + rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))}); if ($source_file.defined) { rep("(load-file \"$source_file\")"); diff --git a/perl6/step7_quote.pl b/perl6/step7_quote.pl index 33e69f14..0bbbb2af 100644 --- a/perl6/step7_quote.pl +++ b/perl6/step7_quote.pl @@ -104,7 +104,7 @@ sub MAIN ($source_file?, *@args) { $repl_env.set('eval', MalCode({ eval($^a, $repl_env) })); $repl_env.set('*ARGV*', MalList([@args.map({ MalString($_) })])); rep(q{(def! not (fn* (a) (if a false true)))}); - rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); + rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))}); if ($source_file.defined) { rep("(load-file \"$source_file\")"); diff --git a/perl6/step8_macros.pl b/perl6/step8_macros.pl index 375388c8..d5f6e55e 100644 --- a/perl6/step8_macros.pl +++ b/perl6/step8_macros.pl @@ -125,7 +125,7 @@ sub MAIN ($source_file?, *@args) { $repl_env.set('eval', MalCode({ eval($^a, $repl_env) })); $repl_env.set('*ARGV*', MalList([@args.map({ MalString($_) })])); rep(q{(def! not (fn* (a) (if a false true)))}); - rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); + rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))}); rep(q{(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 ($source_file.defined) { diff --git a/perl6/step9_try.pl b/perl6/step9_try.pl index 6ce28129..9a658a57 100644 --- a/perl6/step9_try.pl +++ b/perl6/step9_try.pl @@ -135,7 +135,7 @@ sub MAIN ($source_file?, *@args) { $repl_env.set('eval', MalCode({ eval($^a, $repl_env) })); $repl_env.set('*ARGV*', MalList([@args.map({ MalString($_) })])); rep(q{(def! not (fn* (a) (if a false true)))}); - rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); + rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))}); rep(q{(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 ($source_file.defined) { diff --git a/perl6/stepA_mal.pl b/perl6/stepA_mal.pl index c70a96a6..847b4544 100644 --- a/perl6/stepA_mal.pl +++ b/perl6/stepA_mal.pl @@ -136,7 +136,7 @@ sub MAIN ($source_file?, *@args) { $repl_env.set('*ARGV*', MalList([@args.map({ MalString($_) })])); $repl_env.set('*host-language*', MalString('perl6')); rep(q{(def! not (fn* (a) (if a false true)))}); - rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); + rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))}); rep(q{(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 ($source_file.defined) { diff --git a/php/step6_file.php b/php/step6_file.php index 4a291e91..97536767 100644 --- a/php/step6_file.php +++ b/php/step6_file.php @@ -121,7 +121,7 @@ $repl_env->set(_symbol('*ARGV*'), $_argv); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (count($argv) > 1) { rep('(load-file "' . $argv[1] . '")'); diff --git a/php/step7_quote.php b/php/step7_quote.php index 8bcc7107..5b7885be 100644 --- a/php/step7_quote.php +++ b/php/step7_quote.php @@ -145,7 +145,7 @@ $repl_env->set(_symbol('*ARGV*'), $_argv); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); if (count($argv) > 1) { rep('(load-file "' . $argv[1] . '")'); diff --git a/php/step8_macros.php b/php/step8_macros.php index 81ab58b4..20b6d256 100644 --- a/php/step8_macros.php +++ b/php/step8_macros.php @@ -172,7 +172,7 @@ $repl_env->set(_symbol('*ARGV*'), $_argv); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 (count($argv) > 1) { diff --git a/php/step9_try.php b/php/step9_try.php index 323ec3ce..2c84a077 100644 --- a/php/step9_try.php +++ b/php/step9_try.php @@ -190,7 +190,7 @@ $repl_env->set(_symbol('*ARGV*'), $_argv); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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 (count($argv) > 1) { diff --git a/php/stepA_mal.php b/php/stepA_mal.php index dc89ab7d..eef4dfe4 100644 --- a/php/stepA_mal.php +++ b/php/stepA_mal.php @@ -199,7 +199,7 @@ $repl_env->set(_symbol('*ARGV*'), $_argv); // core.mal: defined using the language itself rep("(def! *host-language* \"php\")"); rep("(def! not (fn* (a) (if a false true)))"); -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"); 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)))))))"); // run mal file diff --git a/picolisp/step6_file.l b/picolisp/step6_file.l index 1c3b8896..93254a9f 100644 --- a/picolisp/step6_file.l +++ b/picolisp/step6_file.l @@ -81,7 +81,7 @@ (PRINT (EVAL (READ String) *ReplEnv)) ) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (load-history ".mal_history") diff --git a/picolisp/step7_quote.l b/picolisp/step7_quote.l index 85d88543..e1a107f7 100644 --- a/picolisp/step7_quote.l +++ b/picolisp/step7_quote.l @@ -105,7 +105,7 @@ (PRINT (EVAL (READ String) *ReplEnv)) ) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (load-history ".mal_history") diff --git a/picolisp/step8_macros.l b/picolisp/step8_macros.l index b1445d86..389bb313 100644 --- a/picolisp/step8_macros.l +++ b/picolisp/step8_macros.l @@ -129,7 +129,7 @@ (PRINT (EVAL (READ String) *ReplEnv)) ) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") diff --git a/picolisp/step9_try.l b/picolisp/step9_try.l index 74fe8c27..de258658 100644 --- a/picolisp/step9_try.l +++ b/picolisp/step9_try.l @@ -142,7 +142,7 @@ (PRINT (EVAL (READ String) *ReplEnv)) ) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (load-history ".mal_history") diff --git a/picolisp/stepA_mal.l b/picolisp/stepA_mal.l index 94b5fd2f..005cab33 100644 --- a/picolisp/stepA_mal.l +++ b/picolisp/stepA_mal.l @@ -143,7 +143,7 @@ (PRINT (EVAL (READ String) *ReplEnv)) ) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (load-history ".mal_history") diff --git a/plpgsql/step6_file.sql b/plpgsql/step6_file.sql index 61c87327..3115021b 100644 --- a/plpgsql/step6_file.sql +++ b/plpgsql/step6_file.sql @@ -208,7 +208,7 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' -- core.mal: defined using the language itself SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' -SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' +SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) RETURNS integer AS $$ diff --git a/plpgsql/step7_quote.sql b/plpgsql/step7_quote.sql index 5602aef7..bfcb90e1 100644 --- a/plpgsql/step7_quote.sql +++ b/plpgsql/step7_quote.sql @@ -248,7 +248,7 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' -- core.mal: defined using the language itself SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' -SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' +SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) RETURNS integer AS $$ diff --git a/plpgsql/step8_macros.sql b/plpgsql/step8_macros.sql index fe935af7..ef426f47 100644 --- a/plpgsql/step8_macros.sql +++ b/plpgsql/step8_macros.sql @@ -293,7 +293,7 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' -- core.mal: defined using the language itself SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' -SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' +SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') \g '/dev/null' SELECT mal.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)))))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) diff --git a/plpgsql/step9_try.sql b/plpgsql/step9_try.sql index d3623bd2..7070f6d5 100644 --- a/plpgsql/step9_try.sql +++ b/plpgsql/step9_try.sql @@ -312,7 +312,7 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' -- core.mal: defined using the language itself SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' -SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' +SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') \g '/dev/null' SELECT mal.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)))))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) diff --git a/plpgsql/stepA_mal.sql b/plpgsql/stepA_mal.sql index eb44d4f4..6880a1b4 100644 --- a/plpgsql/stepA_mal.sql +++ b/plpgsql/stepA_mal.sql @@ -313,7 +313,7 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' -- core.mal: defined using the language itself SELECT mal.REP('(def! *host-language* "plpqsql")') \g '/dev/null' SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' -SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' +SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') \g '/dev/null' SELECT mal.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)))))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) diff --git a/plsql/step6_file.sql b/plsql/step6_file.sql index 020bc37f..5ef9e59b 100644 --- a/plsql/step6_file.sql +++ b/plsql/step6_file.sql @@ -231,7 +231,7 @@ BEGIN -- core.mal: defined using the language itself line := REP('(def! not (fn* (a) (if a false true)))'); - line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); IF argv.COUNT() > 0 THEN BEGIN diff --git a/plsql/step7_quote.sql b/plsql/step7_quote.sql index 2c864315..e2f90f06 100644 --- a/plsql/step7_quote.sql +++ b/plsql/step7_quote.sql @@ -266,7 +266,7 @@ BEGIN -- core.mal: defined using the language itself line := REP('(def! not (fn* (a) (if a false true)))'); - line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); IF argv.COUNT() > 0 THEN BEGIN diff --git a/plsql/step8_macros.sql b/plsql/step8_macros.sql index cee72aab..089ad44e 100644 --- a/plsql/step8_macros.sql +++ b/plsql/step8_macros.sql @@ -323,7 +323,7 @@ BEGIN -- core.mal: defined using the language itself line := REP('(def! not (fn* (a) (if a false true)))'); - line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); line := 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 argv.COUNT() > 0 THEN diff --git a/plsql/step9_try.sql b/plsql/step9_try.sql index 2e2bb521..aacb2594 100644 --- a/plsql/step9_try.sql +++ b/plsql/step9_try.sql @@ -409,7 +409,7 @@ BEGIN -- core.mal: defined using the language itself line := REP('(def! not (fn* (a) (if a false true)))'); - line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); line := 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 argv.COUNT() > 0 THEN diff --git a/plsql/stepA_mal.sql b/plsql/stepA_mal.sql index 9df1750d..32be98ef 100644 --- a/plsql/stepA_mal.sql +++ b/plsql/stepA_mal.sql @@ -410,7 +410,7 @@ BEGIN -- core.mal: defined using the language itself line := REP('(def! *host-language* "PL/SQL")'); line := REP('(def! not (fn* (a) (if a false true)))'); - line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); + line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))'); line := 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 argv.COUNT() > 0 THEN diff --git a/powershell/step6_file.ps1 b/powershell/step6_file.ps1 index 9223ad47..dd52d46f 100644 --- a/powershell/step6_file.ps1 +++ b/powershell/step6_file.ps1 @@ -109,7 +109,7 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) # core.mal: defined using the language itself $_ = REP('(def! not (fn* (a) (if a false true)))') -$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') if ($args.Count -gt 0) { diff --git a/powershell/step7_quote.ps1 b/powershell/step7_quote.ps1 index a300db39..f515095f 100644 --- a/powershell/step7_quote.ps1 +++ b/powershell/step7_quote.ps1 @@ -140,7 +140,7 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) # core.mal: defined using the language itself $_ = REP('(def! not (fn* (a) (if a false true)))') -$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') if ($args.Count -gt 0) { diff --git a/powershell/step8_macros.ps1 b/powershell/step8_macros.ps1 index 243131f3..bbfe0f47 100644 --- a/powershell/step8_macros.ps1 +++ b/powershell/step8_macros.ps1 @@ -169,7 +169,7 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) # core.mal: defined using the language itself $_ = REP('(def! not (fn* (a) (if a false true)))') -$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') $_ = 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)))))))") diff --git a/powershell/step9_try.ps1 b/powershell/step9_try.ps1 index e2f8f07f..d12e4619 100644 --- a/powershell/step9_try.ps1 +++ b/powershell/step9_try.ps1 @@ -185,7 +185,7 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) # core.mal: defined using the language itself $_ = REP('(def! not (fn* (a) (if a false true)))') -$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') $_ = 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)))))))") diff --git a/powershell/stepA_mal.ps1 b/powershell/stepA_mal.ps1 index be46d061..25c07e26 100644 --- a/powershell/stepA_mal.ps1 +++ b/powershell/stepA_mal.ps1 @@ -186,7 +186,7 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) # core.mal: defined using the language itself $_ = REP('(def! *host-language* "powershell")') $_ = REP('(def! not (fn* (a) (if a false true)))') -$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') +$_ = REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') $_ = 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)))))))") diff --git a/process/guide.md b/process/guide.md index 9aa8a15b..11163127 100644 --- a/process/guide.md +++ b/process/guide.md @@ -990,7 +990,7 @@ diff -urp ../process/step5_tco.txt ../process/step6_file.txt * Define a `load-file` function using mal itself. In your main program call the `rep` function with this string: - "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))". + "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))". Try out `load-file`: * `(load-file "../tests/incA.mal")` -> `9` @@ -999,7 +999,9 @@ Try out `load-file`: The `load-file` function does the following: * Call `slurp` to read in a file by name. Surround the contents with "(do ...)" so that the whole file will be treated as a single - program AST (abstract syntax tree). + program AST (abstract syntax tree). Add a new line in case the files + ends with a comment. The `nil` ensures a short and predictable result, + instead of what happens to be the last function defined in the loaded file. * Call `read-string` on the string returned from `slurp`. This uses the reader to read/convert the file contents into mal data/AST. * Call `eval` (the one in the REPL environment) on the AST returned diff --git a/process/step6_file.txt b/process/step6_file.txt index 9f14f351..43712c1b 100644 --- a/process/step6_file.txt +++ b/process/step6_file.txt @@ -36,7 +36,7 @@ repl_env.set('*ARGV*, cmdline_args[1..]) ;; core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/process/step7_quote.txt b/process/step7_quote.txt index 1000a097..55039272 100644 --- a/process/step7_quote.txt +++ b/process/step7_quote.txt @@ -41,7 +41,7 @@ repl_env.set('*ARGV*, cmdline_args[1..]) ;; core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/process/step8_macros.txt b/process/step8_macros.txt index 93da781a..1bb37033 100644 --- a/process/step8_macros.txt +++ b/process/step8_macros.txt @@ -50,7 +50,7 @@ repl_env.set('*ARGV*, cmdline_args[1..]) ;; core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/process/step9_try.txt b/process/step9_try.txt index 26418054..092f89ce 100644 --- a/process/step9_try.txt +++ b/process/step9_try.txt @@ -51,7 +51,7 @@ repl_env.set('*ARGV*, cmdline_args[1..]) ;; core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/process/stepA_mal.txt b/process/stepA_mal.txt index b88a5afa..76669c86 100644 --- a/process/stepA_mal.txt +++ b/process/stepA_mal.txt @@ -52,7 +52,7 @@ repl_env.set('*ARGV*, cmdline_args[1..]) ;; core.mal: defined using the language itself rep("(def! *host-language* \"racket\")") rep("(def! not (fn* (a) (if a false true)))") -rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/ps/step6_file.ps b/ps/step6_file.ps index b1a7ddeb..9173cde0 100644 --- a/ps/step6_file.ps +++ b/ps/step6_file.ps @@ -135,7 +135,7 @@ core_ns { _function _ref } forall % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop -(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop +(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\nnil\)"\)\)\)\)\)) RE pop userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments diff --git a/ps/step7_quote.ps b/ps/step7_quote.ps index 51de0dbf..02c85be1 100644 --- a/ps/step7_quote.ps +++ b/ps/step7_quote.ps @@ -169,7 +169,7 @@ core_ns { _function _ref } forall % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop -(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop +(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\nnil\)"\)\)\)\)\)) RE pop userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments diff --git a/ps/step8_macros.ps b/ps/step8_macros.ps index 925b1796..45a681d6 100644 --- a/ps/step8_macros.ps +++ b/ps/step8_macros.ps @@ -211,7 +211,7 @@ core_ns { _function _ref } forall % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop -(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop +(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\nnil\)"\)\)\)\)\)) 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 userdict /ARGUMENTS known { %if command line arguments diff --git a/ps/step9_try.ps b/ps/step9_try.ps index c25168f1..100eeaa0 100644 --- a/ps/step9_try.ps +++ b/ps/step9_try.ps @@ -251,7 +251,7 @@ core_ns { _function _ref } forall % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop -(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop +(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\nnil\)"\)\)\)\)\)) 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 userdict /ARGUMENTS known { %if command line arguments diff --git a/ps/stepA_mal.ps b/ps/stepA_mal.ps index f6032980..e8c3c069 100644 --- a/ps/stepA_mal.ps +++ b/ps/stepA_mal.ps @@ -261,7 +261,7 @@ core_ns { _function _ref } forall % 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 +(\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\nnil\)"\)\)\)\)\)) 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 userdict /ARGUMENTS known { %if command line arguments diff --git a/python/step6_file.py b/python/step6_file.py index 5d10b469..013ad746 100644 --- a/python/step6_file.py +++ b/python/step6_file.py @@ -89,7 +89,7 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if len(sys.argv) >= 2: REP('(load-file "' + sys.argv[1] + '")') diff --git a/python/step7_quote.py b/python/step7_quote.py index 7c97c237..e8b5b8a0 100644 --- a/python/step7_quote.py +++ b/python/step7_quote.py @@ -112,7 +112,7 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if len(sys.argv) >= 2: REP('(load-file "' + sys.argv[1] + '")') diff --git a/python/step8_macros.py b/python/step8_macros.py index 9c8d392a..7cc99816 100644 --- a/python/step8_macros.py +++ b/python/step8_macros.py @@ -133,7 +133,7 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 len(sys.argv) >= 2: diff --git a/python/step9_try.py b/python/step9_try.py index b1b591bc..bebe4598 100644 --- a/python/step9_try.py +++ b/python/step9_try.py @@ -155,7 +155,7 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 len(sys.argv) >= 2: diff --git a/python/stepA_mal.py b/python/stepA_mal.py index c9bae23e..8f4752fa 100644 --- a/python/stepA_mal.py +++ b/python/stepA_mal.py @@ -159,7 +159,7 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) # core.mal: defined using the language itself REP("(def! *host-language* \"python\")") REP("(def! not (fn* (a) (if a false true)))") -REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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 len(sys.argv) >= 2: diff --git a/r/step6_file.r b/r/step6_file.r index 8ca13ff4..c3a22975 100644 --- a/r/step6_file.r +++ b/r/step6_file.r @@ -98,7 +98,7 @@ Env.set(repl_env, "*ARGV*", new.list()) # core.mal: defined using the language itself . <- rep("(def! not (fn* (a) (if a false true)))") -. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") args <- commandArgs(trailingOnly = TRUE) if (length(args) > 0) { diff --git a/r/step7_quote.r b/r/step7_quote.r index 272ff292..4d8719c6 100644 --- a/r/step7_quote.r +++ b/r/step7_quote.r @@ -126,7 +126,7 @@ Env.set(repl_env, "*ARGV*", new.list()) # core.mal: defined using the language itself . <- rep("(def! not (fn* (a) (if a false true)))") -. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") args <- commandArgs(trailingOnly = TRUE) if (length(args) > 0) { diff --git a/r/step8_macros.r b/r/step8_macros.r index 33d251f7..d6ead1ab 100644 --- a/r/step8_macros.r +++ b/r/step8_macros.r @@ -152,7 +152,7 @@ Env.set(repl_env, "*ARGV*", new.list()) # core.mal: defined using the language itself . <- rep("(def! not (fn* (a) (if a false true)))") -. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") . <- 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)))))))") diff --git a/r/step9_try.r b/r/step9_try.r index f3c5d421..d6d460d3 100644 --- a/r/step9_try.r +++ b/r/step9_try.r @@ -166,7 +166,7 @@ Env.set(repl_env, "*ARGV*", new.list()) # core.mal: defined using the language itself . <- rep("(def! not (fn* (a) (if a false true)))") -. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +. <- rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") . <- 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)))))))") diff --git a/r/stepA_mal.r b/r/stepA_mal.r index 2d610526..a73d3270 100644 --- a/r/stepA_mal.r +++ b/r/stepA_mal.r @@ -167,7 +167,7 @@ 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("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") . <- 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)))))))") diff --git a/racket/step6_file.rkt b/racket/step6_file.rkt index 680f84ff..1db7a081 100755 --- a/racket/step6_file.rkt +++ b/racket/step6_file.rkt @@ -79,7 +79,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") ) diff --git a/racket/step7_quote.rkt b/racket/step7_quote.rkt index bf13e00d..9973f25c 100755 --- a/racket/step7_quote.rkt +++ b/racket/step7_quote.rkt @@ -101,7 +101,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") ) diff --git a/racket/step8_macros.rkt b/racket/step8_macros.rkt index ebcb71e8..a592637e 100755 --- a/racket/step8_macros.rkt +++ b/racket/step8_macros.rkt @@ -124,7 +124,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ) diff --git a/racket/step9_try.rkt b/racket/step9_try.rkt index 06ec7581..49edd060 100755 --- a/racket/step9_try.rkt +++ b/racket/step9_try.rkt @@ -140,7 +140,7 @@ ;; core.mal: defined using the language itself (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ) diff --git a/racket/stepA_mal.rkt b/racket/stepA_mal.rkt index dfdfb3ad..6a96ca2b 100755 --- a/racket/stepA_mal.rkt +++ b/racket/stepA_mal.rkt @@ -141,7 +141,7 @@ ;; core.mal: defined using the language itself (rep "(def! *host-language* \"racket\")") (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") ) diff --git a/rexx/step6_file.rexx b/rexx/step6_file.rexx index fa122317..6c8d8279 100644 --- a/rexx/step6_file.rexx +++ b/rexx/step6_file.rexx @@ -194,7 +194,7 @@ main: /* core.mal: defined using the language itself */ x = re("(def! not (fn* (a) (if a false true)))") - x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') + x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') err = "" if command_line_args.0 > 0 then do diff --git a/rexx/step7_quote.rexx b/rexx/step7_quote.rexx index 648317c5..4b6caa53 100644 --- a/rexx/step7_quote.rexx +++ b/rexx/step7_quote.rexx @@ -214,7 +214,7 @@ main: /* core.mal: defined using the language itself */ x = re("(def! not (fn* (a) (if a false true)))") - x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') + x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') err = "" if command_line_args.0 > 0 then do diff --git a/rexx/step8_macros.rexx b/rexx/step8_macros.rexx index 60482a09..ed9ffb8d 100644 --- a/rexx/step8_macros.rexx +++ b/rexx/step8_macros.rexx @@ -243,7 +243,7 @@ main: /* core.mal: defined using the language itself */ x = re("(def! not (fn* (a) (if a false true)))") - x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') + x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') x = 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)))))))"); err = "" diff --git a/rexx/step9_try.rexx b/rexx/step9_try.rexx index d201b37a..f0807832 100644 --- a/rexx/step9_try.rexx +++ b/rexx/step9_try.rexx @@ -259,7 +259,7 @@ main: /* core.mal: defined using the language itself */ x = re("(def! not (fn* (a) (if a false true)))") - x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') + x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') x = 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)))))))"); err = "" diff --git a/rexx/stepA_mal.rexx b/rexx/stepA_mal.rexx index 3c127a3f..a3a9d0f7 100644 --- a/rexx/stepA_mal.rexx +++ b/rexx/stepA_mal.rexx @@ -261,7 +261,7 @@ main: /* core.mal: defined using the language itself */ x = re('(def! *host-language* "rexx")') x = re("(def! not (fn* (a) (if a false true)))") - x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') + x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))') x = 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)))))))"); err = "" diff --git a/rpython/step6_file.py b/rpython/step6_file.py index 06b8794a..47439276 100644 --- a/rpython/step6_file.py +++ b/rpython/step6_file.py @@ -115,7 +115,7 @@ def entry_point(argv): # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if len(argv) >= 2: REP('(load-file "' + argv[1] + '")', repl_env) diff --git a/rpython/step7_quote.py b/rpython/step7_quote.py index 1db96690..456e8de9 100644 --- a/rpython/step7_quote.py +++ b/rpython/step7_quote.py @@ -142,7 +142,7 @@ def entry_point(argv): # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if len(argv) >= 2: REP('(load-file "' + argv[1] + '")', repl_env) diff --git a/rpython/step8_macros.py b/rpython/step8_macros.py index 811cd14b..83cac9fd 100644 --- a/rpython/step8_macros.py +++ b/rpython/step8_macros.py @@ -166,7 +166,7 @@ def entry_point(argv): # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if len(argv) >= 2: diff --git a/rpython/step9_try.py b/rpython/step9_try.py index 9c58d7b2..c4a273e2 100644 --- a/rpython/step9_try.py +++ b/rpython/step9_try.py @@ -184,7 +184,7 @@ def entry_point(argv): # core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if len(argv) >= 2: diff --git a/rpython/stepA_mal.py b/rpython/stepA_mal.py index 6c73a48c..dce3b40d 100644 --- a/rpython/stepA_mal.py +++ b/rpython/stepA_mal.py @@ -194,7 +194,7 @@ def entry_point(argv): # core.mal: defined using the language itself REP("(def! *host-language* \"rpython\")", repl_env) REP("(def! not (fn* (a) (if a false true)))", repl_env) - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) 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)))))))", repl_env) if len(argv) >= 2: diff --git a/ruby/step6_file.rb b/ruby/step6_file.rb index 0f44251a..0a197412 100644 --- a/ruby/step6_file.rb +++ b/ruby/step6_file.rb @@ -98,7 +98,7 @@ repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) # core.mal: defined using the language itself RE["(def! not (fn* (a) (if a false true)))"] -RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"] +RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"] if ARGV.size > 0 RE["(load-file \"" + ARGV[0] + "\")"] diff --git a/ruby/step7_quote.rb b/ruby/step7_quote.rb index 5cb27372..e099fb28 100644 --- a/ruby/step7_quote.rb +++ b/ruby/step7_quote.rb @@ -118,7 +118,7 @@ repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) # core.mal: defined using the language itself RE["(def! not (fn* (a) (if a false true)))"] -RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"] +RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"] if ARGV.size > 0 RE["(load-file \"" + ARGV[0] + "\")"] diff --git a/ruby/step8_macros.rb b/ruby/step8_macros.rb index 46a64e53..3dcce5c8 100644 --- a/ruby/step8_macros.rb +++ b/ruby/step8_macros.rb @@ -145,7 +145,7 @@ repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) # core.mal: defined using the language itself RE["(def! not (fn* (a) (if a false true)))"] -RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"] +RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"] 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)))))))"] if ARGV.size > 0 diff --git a/ruby/step9_try.rb b/ruby/step9_try.rb index 96fc5ee2..b0aa5c88 100644 --- a/ruby/step9_try.rb +++ b/ruby/step9_try.rb @@ -160,7 +160,7 @@ repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) # core.mal: defined using the language itself RE["(def! not (fn* (a) (if a false true)))"] -RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"] +RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"] 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)))))))"] if ARGV.size > 0 diff --git a/ruby/stepA_mal.rb b/ruby/stepA_mal.rb index 14f7f785..037cd8cc 100644 --- a/ruby/stepA_mal.rb +++ b/ruby/stepA_mal.rb @@ -167,7 +167,7 @@ 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["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"] 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)))))))"] if ARGV.size > 0 diff --git a/rust/step6_file.rs b/rust/step6_file.rs index 45032b9e..b4a6c33b 100644 --- a/rust/step6_file.rs +++ b/rust/step6_file.rs @@ -192,7 +192,7 @@ fn main() { // core.mal: defined using the language itself let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); - let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); + let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", &repl_env); // Invoked with arguments if let Some(f) = arg1 { diff --git a/rust/step7_quote.rs b/rust/step7_quote.rs index 1555e2a9..0c9affe6 100644 --- a/rust/step7_quote.rs +++ b/rust/step7_quote.rs @@ -234,7 +234,7 @@ fn main() { // core.mal: defined using the language itself let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); - let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); + let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", &repl_env); // Invoked with arguments if let Some(f) = arg1 { diff --git a/rust/step8_macros.rs b/rust/step8_macros.rs index 02cb6de1..9ab719c6 100644 --- a/rust/step8_macros.rs +++ b/rust/step8_macros.rs @@ -301,7 +301,7 @@ fn main() { // core.mal: defined using the language itself let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); - let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); + let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", &repl_env); let _ = 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)))))))", &repl_env); diff --git a/rust/step9_try.rs b/rust/step9_try.rs index 1d91d762..c0485f62 100644 --- a/rust/step9_try.rs +++ b/rust/step9_try.rs @@ -322,7 +322,7 @@ fn main() { // core.mal: defined using the language itself let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); - let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); + let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", &repl_env); let _ = 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)))))))", &repl_env); diff --git a/rust/stepA_mal.rs b/rust/stepA_mal.rs index 2692fdde..ed775271 100644 --- a/rust/stepA_mal.rs +++ b/rust/stepA_mal.rs @@ -325,7 +325,7 @@ fn main() { // core.mal: defined using the language itself let _ = rep("(def! *host-language* \"rust\")", &repl_env); let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); - let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); + let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", &repl_env); let _ = 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)))))))", &repl_env); diff --git a/scala/step6_file.scala b/scala/step6_file.scala index b91a9b1c..0a9d979e 100644 --- a/scala/step6_file.scala +++ b/scala/step6_file.scala @@ -108,7 +108,7 @@ object step6_file { // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if (args.length > 0) { REP("(load-file \"" + args(0) + "\")") diff --git a/scala/step7_quote.scala b/scala/step7_quote.scala index a8cbec41..81e6625d 100644 --- a/scala/step7_quote.scala +++ b/scala/step7_quote.scala @@ -141,7 +141,7 @@ object step7_quote { // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if (args.length > 0) { REP("(load-file \"" + args(0) + "\")") diff --git a/scala/step8_macros.scala b/scala/step8_macros.scala index 06206125..aebecf46 100644 --- a/scala/step8_macros.scala +++ b/scala/step8_macros.scala @@ -184,7 +184,7 @@ object step8_macros { // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") diff --git a/scala/step9_try.scala b/scala/step9_try.scala index fe6df011..70227ada 100644 --- a/scala/step9_try.scala +++ b/scala/step9_try.scala @@ -205,7 +205,7 @@ object step9_try { // core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") diff --git a/scala/stepA_mal.scala b/scala/stepA_mal.scala index bbdbd098..77ced958 100644 --- a/scala/stepA_mal.scala +++ b/scala/stepA_mal.scala @@ -206,7 +206,7 @@ object stepA_mal { // core.mal: defined using the language itself REP("(def! *host-language* \"scala\")") REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") diff --git a/scheme/step6_file.scm b/scheme/step6_file.scm index 1c7e956f..bb4fed07 100644 --- a/scheme/step6_file.scm +++ b/scheme/step6_file.scm @@ -105,7 +105,7 @@ (env-set repl-env '*ARGV* (mal-list (map mal-string (cdr-safe args)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (define (main) (let loop () diff --git a/scheme/step7_quote.scm b/scheme/step7_quote.scm index f0f2c805..c02b0c59 100644 --- a/scheme/step7_quote.scm +++ b/scheme/step7_quote.scm @@ -133,7 +133,7 @@ (env-set repl-env '*ARGV* (mal-list (map mal-string (cdr-safe args)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (define (main) (let loop () diff --git a/scheme/step8_macros.scm b/scheme/step8_macros.scm index 07bc86c7..eddf06f7 100644 --- a/scheme/step8_macros.scm +++ b/scheme/step8_macros.scm @@ -170,7 +170,7 @@ (env-set repl-env '*ARGV* (mal-list (map mal-string (cdr-safe args)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") diff --git a/scheme/step9_try.scm b/scheme/step9_try.scm index a8d99cde..85198054 100644 --- a/scheme/step9_try.scm +++ b/scheme/step9_try.scm @@ -188,7 +188,7 @@ (env-set repl-env '*ARGV* (mal-list (map mal-string (cdr-safe args)))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") diff --git a/scheme/stepA_mal.scm b/scheme/stepA_mal.scm index af1f1045..26bb4805 100644 --- a/scheme/stepA_mal.scm +++ b/scheme/stepA_mal.scm @@ -190,7 +190,7 @@ (env-set repl-env '*host-language* (mal-string (str "scheme (" scheme ")")))) (rep "(def! not (fn* (a) (if a false true)))") -(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") (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)))))))") (define (main) diff --git a/skew/step6_file.sk b/skew/step6_file.sk index 702fb2f2..9ab04fab 100644 --- a/skew/step6_file.sk +++ b/skew/step6_file.sk @@ -94,7 +94,7 @@ def main { # core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if argv.count > 0 { RE("(load-file \"" + argv[0] + "\")") diff --git a/skew/step7_quote.sk b/skew/step7_quote.sk index 8594e61a..ed2f3476 100644 --- a/skew/step7_quote.sk +++ b/skew/step7_quote.sk @@ -121,7 +121,7 @@ def main { # core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if argv.count > 0 { RE("(load-file \"" + argv[0] + "\")") diff --git a/skew/step8_macros.sk b/skew/step8_macros.sk index 3c6307b7..ed76ff27 100644 --- a/skew/step8_macros.sk +++ b/skew/step8_macros.sk @@ -151,7 +151,7 @@ def main { # core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") if argv.count > 0 { diff --git a/skew/step9_try.sk b/skew/step9_try.sk index bb93792a..fb697993 100644 --- a/skew/step9_try.sk +++ b/skew/step9_try.sk @@ -165,7 +165,7 @@ def main { # core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))") - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") if argv.count > 0 { diff --git a/skew/stepA_mal.sk b/skew/stepA_mal.sk index 983c3e10..09ee5094 100644 --- a/skew/stepA_mal.sk +++ b/skew/stepA_mal.sk @@ -166,7 +166,7 @@ def main { # core.mal: defined using the language itself RE("(def! *host-language* \"skew\")") RE("(def! not (fn* (a) (if a false true)))") - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") 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)))))))") if argv.count > 0 { diff --git a/swift/step6_file.swift b/swift/step6_file.swift index 45927eae..962fd8d8 100644 --- a/swift/step6_file.swift +++ b/swift/step6_file.swift @@ -403,7 +403,7 @@ func main() { load_builtins(env) RE("(def! not (fn* (a) (if a false true)))", env) - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env) + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", env) env.set(kSymbolEval, make_builtin({ try! unwrap_args($0) { diff --git a/swift/step7_quote.swift b/swift/step7_quote.swift index e5324d1d..89a84d2a 100644 --- a/swift/step7_quote.swift +++ b/swift/step7_quote.swift @@ -528,7 +528,7 @@ func main() { load_builtins(env) RE("(def! not (fn* (a) (if a false true)))", env) - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env) + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", env) env.set(kSymbolEval, make_builtin({ try! unwrap_args($0) { diff --git a/swift/step8_macros.swift b/swift/step8_macros.swift index eb99f0fb..c2a288b5 100644 --- a/swift/step8_macros.swift +++ b/swift/step8_macros.swift @@ -580,7 +580,7 @@ func main() { load_builtins(env) RE("(def! not (fn* (a) (if a false true)))", env) - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env) + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", env) 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)))))))", env) diff --git a/swift/step9_try.swift b/swift/step9_try.swift index 40973200..4c5cb9e2 100644 --- a/swift/step9_try.swift +++ b/swift/step9_try.swift @@ -613,7 +613,7 @@ func main() { load_builtins(env) RE("(def! not (fn* (a) (if a false true)))", env) - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env) + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", env) 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)))))))", env) diff --git a/swift/stepA_mal.swift b/swift/stepA_mal.swift index cbdaa79a..33ab764c 100644 --- a/swift/stepA_mal.swift +++ b/swift/stepA_mal.swift @@ -614,7 +614,7 @@ func main() { RE("(def! *host-language* \"swift\")", env) RE("(def! not (fn* (a) (if a false true)))", env) - RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env) + RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", env) 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)))))))", env) diff --git a/swift3/Sources/step6_file/main.swift b/swift3/Sources/step6_file/main.swift index e24a6b39..876e900e 100644 --- a/swift3/Sources/step6_file/main.swift +++ b/swift3/Sources/step6_file/main.swift @@ -127,7 +127,7 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) // core.mal: defined using the language itself try rep("(def! not (fn* (a) (if a false true)))") -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if CommandLine.arguments.count > 1 { diff --git a/swift3/Sources/step7_quote/main.swift b/swift3/Sources/step7_quote/main.swift index 252d89f6..37447cae 100644 --- a/swift3/Sources/step7_quote/main.swift +++ b/swift3/Sources/step7_quote/main.swift @@ -165,7 +165,7 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) // core.mal: defined using the language itself try rep("(def! not (fn* (a) (if a false true)))") -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") if CommandLine.arguments.count > 1 { diff --git a/swift3/Sources/step8_macros/main.swift b/swift3/Sources/step8_macros/main.swift index 46c3cc3a..b15332e5 100644 --- a/swift3/Sources/step8_macros/main.swift +++ b/swift3/Sources/step8_macros/main.swift @@ -215,7 +215,7 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) // core.mal: defined using the language itself try rep("(def! not (fn* (a) (if a false true)))") -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") try 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)))))))") diff --git a/swift3/Sources/step9_try/main.swift b/swift3/Sources/step9_try/main.swift index 7344bba4..ce2ba65c 100644 --- a/swift3/Sources/step9_try/main.swift +++ b/swift3/Sources/step9_try/main.swift @@ -248,7 +248,7 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) // core.mal: defined using the language itself try rep("(def! not (fn* (a) (if a false true)))") -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") try 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)))))))") diff --git a/swift3/Sources/stepA_mal/main.swift b/swift3/Sources/stepA_mal/main.swift index 55d81547..3473ec19 100644 --- a/swift3/Sources/stepA_mal/main.swift +++ b/swift3/Sources/stepA_mal/main.swift @@ -249,7 +249,7 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) // core.mal: defined using the language itself try rep("(def! *host-language* \"swift\")") try rep("(def! not (fn* (a) (if a false true)))") -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") try 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)))))))") diff --git a/swift4/Sources/step6_file/main.swift b/swift4/Sources/step6_file/main.swift index 48a8ef6a..6a20514e 100644 --- a/swift4/Sources/step6_file/main.swift +++ b/swift4/Sources/step6_file/main.swift @@ -113,7 +113,7 @@ repl_env.set(Function(fn: { try EVAL($0[0], env: repl_env) }), forKey: Symbol("e repl_env.set([], forKey: Symbol("*ARGV*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env: repl_env) if CommandLine.argc > 1 { let fileName = CommandLine.arguments[1], diff --git a/swift4/Sources/step7_quote/main.swift b/swift4/Sources/step7_quote/main.swift index 8c1d408f..efa4af51 100644 --- a/swift4/Sources/step7_quote/main.swift +++ b/swift4/Sources/step7_quote/main.swift @@ -135,7 +135,7 @@ repl_env.set(Function(fn: { try EVAL($0[0], env: repl_env) }), forKey: Symbol("e repl_env.set([], forKey: Symbol("*ARGV*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env: repl_env) if CommandLine.argc > 1 { let fileName = CommandLine.arguments[1], diff --git a/swift4/Sources/step8_macros/main.swift b/swift4/Sources/step8_macros/main.swift index b9d1f48a..82c69a60 100644 --- a/swift4/Sources/step8_macros/main.swift +++ b/swift4/Sources/step8_macros/main.swift @@ -164,7 +164,7 @@ repl_env.set(Function(fn: { try EVAL($0[0], env: repl_env) }), forKey: Symbol("e repl_env.set([], forKey: Symbol("*ARGV*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env: repl_env) try 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)))))))", env: repl_env) if CommandLine.argc > 1 { diff --git a/swift4/Sources/step9_try/main.swift b/swift4/Sources/step9_try/main.swift index c2bc8ec6..857dcfd2 100644 --- a/swift4/Sources/step9_try/main.swift +++ b/swift4/Sources/step9_try/main.swift @@ -176,7 +176,7 @@ repl_env.set(Function(fn: { try EVAL($0[0], env: repl_env) }), forKey: Symbol("e repl_env.set([], forKey: Symbol("*ARGV*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env: repl_env) try 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)))))))", env: repl_env) if CommandLine.argc > 1 { diff --git a/swift4/Sources/stepA_mal/main.swift b/swift4/Sources/stepA_mal/main.swift index a1f9eb51..9c6192ad 100644 --- a/swift4/Sources/stepA_mal/main.swift +++ b/swift4/Sources/stepA_mal/main.swift @@ -178,7 +178,7 @@ repl_env.set("Swift4", forKey: Symbol("*host-language*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) -try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) +try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env: repl_env) try 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)))))))", env: repl_env) if CommandLine.argc > 1 { diff --git a/tcl/step6_file.tcl b/tcl/step6_file.tcl index 25a7c83f..193df2c1 100644 --- a/tcl/step6_file.tcl +++ b/tcl/step6_file.tcl @@ -148,7 +148,7 @@ $repl_env set "*ARGV*" [list_new $argv_list] # core.mal: defined using the language itself RE "(def! not (fn* (a) (if a false true)))" $repl_env -RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env +RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))" $repl_env fconfigure stdout -translation binary diff --git a/tcl/step7_quote.tcl b/tcl/step7_quote.tcl index 770d6960..6fbfe56d 100644 --- a/tcl/step7_quote.tcl +++ b/tcl/step7_quote.tcl @@ -175,7 +175,7 @@ $repl_env set "*ARGV*" [list_new $argv_list] # core.mal: defined using the language itself RE "(def! not (fn* (a) (if a false true)))" $repl_env -RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env +RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))" $repl_env fconfigure stdout -translation binary diff --git a/tcl/step8_macros.tcl b/tcl/step8_macros.tcl index 9ee25aa3..a9ecdb9e 100644 --- a/tcl/step8_macros.tcl +++ b/tcl/step8_macros.tcl @@ -225,7 +225,7 @@ $repl_env set "*ARGV*" [list_new $argv_list] # core.mal: defined using the language itself RE "(def! not (fn* (a) (if a false true)))" $repl_env -RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env +RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))" $repl_env 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)))))))" $repl_env fconfigure stdout -translation binary diff --git a/tcl/step9_try.tcl b/tcl/step9_try.tcl index dd4ef788..3fd8ef26 100644 --- a/tcl/step9_try.tcl +++ b/tcl/step9_try.tcl @@ -243,7 +243,7 @@ $repl_env set "*ARGV*" [list_new $argv_list] # core.mal: defined using the language itself RE "(def! not (fn* (a) (if a false true)))" $repl_env -RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env +RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))" $repl_env 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)))))))" $repl_env fconfigure stdout -translation binary diff --git a/tcl/stepA_mal.tcl b/tcl/stepA_mal.tcl index 71c09c7a..b5bf5a79 100644 --- a/tcl/stepA_mal.tcl +++ b/tcl/stepA_mal.tcl @@ -247,7 +247,7 @@ $repl_env set "*ARGV*" [list_new $argv_list] # core.mal: defined using the language itself RE "(def! *host-language* \"tcl\")" $repl_env RE "(def! not (fn* (a) (if a false true)))" $repl_env -RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env +RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))" $repl_env 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)))))))" $repl_env fconfigure stdout -translation binary diff --git a/tests/computations.mal b/tests/computations.mal index 24dc00cb..9e418d99 100644 --- a/tests/computations.mal +++ b/tests/computations.mal @@ -15,5 +15,3 @@ (if (<= n 1) n (+ (fib (- n 1)) (fib (- n 2)))))) - -nil diff --git a/tests/incB.mal b/tests/incB.mal index 519bdf41..4dd43ad4 100644 --- a/tests/incB.mal +++ b/tests/incB.mal @@ -3,8 +3,4 @@ (def! inc5 (fn* (a) ;; a comment after code (+ 5 a))) -(prn "incB.mal finished") -"incB.mal return string" - -;; ending comment - +;; ending comment without final new line \ No newline at end of file diff --git a/tests/incC.mal b/tests/incC.mal index e6f5041e..d647d880 100644 --- a/tests/incC.mal +++ b/tests/incC.mal @@ -1,6 +1,2 @@ (def! mymap {"a" 1}) - -(prn "incC.mal finished") -"incC.mal return string" - diff --git a/tests/lib/load-file-once.mal b/tests/lib/load-file-once.mal index 65e40a99..ac84cb01 100644 --- a/tests/lib/load-file-once.mal +++ b/tests/lib/load-file-once.mal @@ -3,8 +3,12 @@ ;; The counter is increased by each `load-file`. (load-file "../tests/lib/load-file-once-inc.mal") +;=>nil +@counter ;=>1 (load-file "../tests/lib/load-file-once-inc.mal") +;=>nil +@counter ;=>2 ;; load-file-once is available @@ -13,6 +17,8 @@ ;; First import actually calls `load-file`. (load-file-once "../tests/lib/load-file-once-inc.mal") +;=>nil +@counter ;=>3 ;; Later imports do nothing. diff --git a/tests/step6_file.mal b/tests/step6_file.mal index dd3bd661..49a8fb6f 100644 --- a/tests/step6_file.mal +++ b/tests/step6_file.mal @@ -32,6 +32,7 @@ ;; Testing load-file (load-file "../tests/inc.mal") +;=>nil (inc1 7) ;=>8 (inc2 7) @@ -129,8 +130,7 @@ ;; Testing comments in a file (load-file "../tests/incB.mal") -;/"incB.mal finished" -;=>"incB.mal return string" +;=>nil (inc4 7) ;=>11 (inc5 7) @@ -138,6 +138,7 @@ ;; Testing map literal across multiple lines in a file (load-file "../tests/incC.mal") +;=>nil mymap ;=>{"a" 1} diff --git a/tests/step7_quote.mal b/tests/step7_quote.mal index c1c07f5c..e2c12248 100644 --- a/tests/step7_quote.mal +++ b/tests/step7_quote.mal @@ -182,4 +182,3 @@ b ;=>(1 1 "b" "d" 3) ;;; TODO: fix this ;;;;=>[1 1 "b" "d" 3] - diff --git a/tests/stepA_mal.mal b/tests/stepA_mal.mal index ee20474e..d4ebb671 100644 --- a/tests/stepA_mal.mal +++ b/tests/stepA_mal.mal @@ -275,6 +275,7 @@ ;; Loading sumdown from computations.mal (load-file "../tests/computations.mal") +;=>nil ;; ;; Testing time-ms function diff --git a/ts/step6_file.ts b/ts/step6_file.ts index d86525f6..10747e6e 100644 --- a/ts/step6_file.ts +++ b/ts/step6_file.ts @@ -161,7 +161,7 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))`); +rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))`); if (typeof process !== "undefined" && 2 < process.argv.length) { replEnv.set(MalSymbol.get("*ARGV*"), new MalList(process.argv.slice(3).map(s => new MalString(s)))); diff --git a/ts/step7_quote.ts b/ts/step7_quote.ts index df84c683..14867924 100644 --- a/ts/step7_quote.ts +++ b/ts/step7_quote.ts @@ -207,7 +207,7 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))`); +rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))`); if (typeof process !== "undefined" && 2 < process.argv.length) { replEnv.set(MalSymbol.get("*ARGV*"), new MalList(process.argv.slice(3).map(s => new MalString(s)))); diff --git a/ts/step8_macros.ts b/ts/step8_macros.ts index f81fa5b8..537c4194 100644 --- a/ts/step8_macros.ts +++ b/ts/step8_macros.ts @@ -274,7 +274,7 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))`); +rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))`); 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 (typeof process !== "undefined" && 2 < process.argv.length) { diff --git a/ts/step9_try.ts b/ts/step9_try.ts index 2074b787..d07f304c 100644 --- a/ts/step9_try.ts +++ b/ts/step9_try.ts @@ -299,7 +299,7 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); // core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))"); -rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))`); +rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))`); 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 (typeof process !== "undefined" && 2 < process.argv.length) { diff --git a/ts/stepA_mal.ts b/ts/stepA_mal.ts index c5bbf31c..6f0a042c 100644 --- a/ts/stepA_mal.ts +++ b/ts/stepA_mal.ts @@ -300,7 +300,7 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); // core.mal: defined using the language itself rep(`(def! *host-language* "TypeScript")`); rep("(def! not (fn* (a) (if a false true)))"); -rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))`); +rep(`(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))`); 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 (typeof process !== "undefined" && 2 < process.argv.length) { diff --git a/vala/step6_file.vala b/vala/step6_file.vala index 3bdd83c9..8177d75b 100644 --- a/vala/step6_file.vala +++ b/vala/step6_file.vala @@ -238,7 +238,7 @@ class Mal.Main : GLib.Object { env.set(new Mal.Sym("eval"), new Mal.BuiltinFunctionEval(env)); setup("(def! not (fn* (a) (if a false true)))", env); - setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); + setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env); var ARGV = new GLib.List(); if (args.length > 1) { diff --git a/vala/step7_quote.vala b/vala/step7_quote.vala index 4fc745f9..10fb43cd 100644 --- a/vala/step7_quote.vala +++ b/vala/step7_quote.vala @@ -297,7 +297,7 @@ class Mal.Main : GLib.Object { env.set(new Mal.Sym("eval"), new Mal.BuiltinFunctionEval(env)); setup("(def! not (fn* (a) (if a false true)))", env); - setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); + setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env); var ARGV = new GLib.List(); if (args.length > 1) { diff --git a/vala/step8_macros.vala b/vala/step8_macros.vala index 8c0088cb..ef638719 100644 --- a/vala/step8_macros.vala +++ b/vala/step8_macros.vala @@ -335,7 +335,7 @@ class Mal.Main : GLib.Object { env.set(new Mal.Sym("eval"), new Mal.BuiltinFunctionEval(env)); setup("(def! not (fn* (a) (if a false true)))", env); - setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); + setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env); setup("(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)))))))", env); var ARGV = new GLib.List(); diff --git a/vala/step9_try.vala b/vala/step9_try.vala index f6d5222d..9cd3d60f 100644 --- a/vala/step9_try.vala +++ b/vala/step9_try.vala @@ -373,7 +373,7 @@ class Mal.Main : GLib.Object { env.set(new Mal.Sym("eval"), new Mal.BuiltinFunctionEval(env)); setup("(def! not (fn* (a) (if a false true)))", env); - setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); + setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env); setup("(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)))))))", env); var ARGV = new GLib.List(); diff --git a/vala/stepA_mal.vala b/vala/stepA_mal.vala index 349c6078..df75f81f 100644 --- a/vala/stepA_mal.vala +++ b/vala/stepA_mal.vala @@ -374,7 +374,7 @@ class Mal.Main : GLib.Object { env.set(new Mal.Sym("*host-language*"), new Mal.String("vala")); setup("(def! not (fn* (a) (if a false true)))", env); - setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); + setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", env); setup("(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)))))))", env); var ARGV = new GLib.List(); diff --git a/vb/step6_file.vb b/vb/step6_file.vb index 9ea0e9f8..8c9c4350 100644 --- a/vb/step6_file.vb +++ b/vb/step6_file.vb @@ -181,7 +181,7 @@ Namespace Mal ' core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))") If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") diff --git a/vb/step7_quote.vb b/vb/step7_quote.vb index f38741ef..f3ea0309 100644 --- a/vb/step7_quote.vb +++ b/vb/step7_quote.vb @@ -214,7 +214,7 @@ Namespace Mal ' core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))") If args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") diff --git a/vb/step8_macros.vb b/vb/step8_macros.vb index 32e102d1..a07d0724 100644 --- a/vb/step8_macros.vb +++ b/vb/step8_macros.vb @@ -252,7 +252,7 @@ Namespace Mal ' core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))") 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.Length > fileIdx Then diff --git a/vb/step9_try.vb b/vb/step9_try.vb index 83bd1bf7..b184c963 100644 --- a/vb/step9_try.vb +++ b/vb/step9_try.vb @@ -275,7 +275,7 @@ Namespace Mal ' core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))") 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.Length > fileIdx Then diff --git a/vb/stepA_mal.vb b/vb/stepA_mal.vb index b10b43c2..1e99f79a 100644 --- a/vb/stepA_mal.vb +++ b/vb/stepA_mal.vb @@ -276,7 +276,7 @@ Namespace Mal ' core.mal: defined using the language itself REP("(def! *host-language* ""VB.NET"")") REP("(def! not (fn* (a) (if a false true)))") - REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))") + REP("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))") 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.Length > fileIdx Then diff --git a/vhdl/step6_file.vhdl b/vhdl/step6_file.vhdl index be9727f2..2bcb3fbc 100644 --- a/vhdl/step6_file.vhdl +++ b/vhdl/step6_file.vhdl @@ -302,7 +302,7 @@ architecture test of step6_file is -- core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); - RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); + RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & "\nnil)" & '"' & ")))))", repl_env, dummy_val, err); if program_file /= null then REP("(load-file " & '"' & program_file.all & '"' & ")", repl_env, result, err); diff --git a/vhdl/step7_quote.vhdl b/vhdl/step7_quote.vhdl index fdfc2efd..241fae79 100644 --- a/vhdl/step7_quote.vhdl +++ b/vhdl/step7_quote.vhdl @@ -351,7 +351,7 @@ architecture test of step7_quote is -- core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); - RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); + RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & "\nnil)" & '"' & ")))))", repl_env, dummy_val, err); if program_file /= null then REP("(load-file " & '"' & program_file.all & '"' & ")", repl_env, result, err); diff --git a/vhdl/step8_macros.vhdl b/vhdl/step8_macros.vhdl index 028f8545..66b1174c 100644 --- a/vhdl/step8_macros.vhdl +++ b/vhdl/step8_macros.vhdl @@ -409,7 +409,7 @@ architecture test of step8_macros is -- core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); - RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); + RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & "\nnil)" & '"' & ")))))", repl_env, dummy_val, err); 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)))))))", repl_env, dummy_val, err); if program_file /= null then diff --git a/vhdl/step9_try.vhdl b/vhdl/step9_try.vhdl index ece0ceab..217d5030 100644 --- a/vhdl/step9_try.vhdl +++ b/vhdl/step9_try.vhdl @@ -467,7 +467,7 @@ architecture test of step9_try is -- core.mal: defined using the language itself RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); - RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); + RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & "\nnil)" & '"' & ")))))", repl_env, dummy_val, err); 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)))))))", repl_env, dummy_val, err); if program_file /= null then diff --git a/vhdl/stepA_mal.vhdl b/vhdl/stepA_mal.vhdl index 80812c16..5cc6b26d 100644 --- a/vhdl/stepA_mal.vhdl +++ b/vhdl/stepA_mal.vhdl @@ -468,7 +468,7 @@ architecture test of stepA_mal is -- core.mal: defined using the language itself RE("(def! *host-language* " & '"' & "vhdl" & '"' & ")", repl_env, dummy_val, err); RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); - RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); + RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & "\nnil)" & '"' & ")))))", repl_env, dummy_val, err); 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)))))))", repl_env, dummy_val, err); if program_file /= null then diff --git a/vimscript/step6_file.vim b/vimscript/step6_file.vim index e7c8c62a..714f3d7f 100644 --- a/vimscript/step6_file.vim +++ b/vimscript/step6_file.vim @@ -132,7 +132,7 @@ endfor call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! not (fn* (a) (if a false true)))", repl_env) -call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) +call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if !empty(argv()) call RE('(load-file "' . argv(0) . '")', repl_env) diff --git a/vimscript/step7_quote.vim b/vimscript/step7_quote.vim index 7ee66b88..a634c059 100644 --- a/vimscript/step7_quote.vim +++ b/vimscript/step7_quote.vim @@ -155,7 +155,7 @@ endfor call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! not (fn* (a) (if a false true)))", repl_env) -call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) +call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) if !empty(argv()) call RE('(load-file "' . argv(0) . '")', repl_env) diff --git a/vimscript/step8_macros.vim b/vimscript/step8_macros.vim index c64268df..770d7ae4 100644 --- a/vimscript/step8_macros.vim +++ b/vimscript/step8_macros.vim @@ -191,7 +191,7 @@ endfor call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! not (fn* (a) (if a false true)))", repl_env) -call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) +call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) call 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)))))))", repl_env) if !empty(argv()) diff --git a/vimscript/step9_try.vim b/vimscript/step9_try.vim index 5f826438..6dabcdf2 100644 --- a/vimscript/step9_try.vim +++ b/vimscript/step9_try.vim @@ -223,7 +223,7 @@ endfor call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! not (fn* (a) (if a false true)))", repl_env) -call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) +call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) call 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)))))))", repl_env) if !empty(argv()) diff --git a/vimscript/stepA_mal.vim b/vimscript/stepA_mal.vim index 063a8f71..6661dd22 100644 --- a/vimscript/stepA_mal.vim +++ b/vimscript/stepA_mal.vim @@ -224,7 +224,7 @@ call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! *host-language* \"vimscript\")", repl_env) call RE("(def! not (fn* (a) (if a false true)))", repl_env) -call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) +call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env) call 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)))))))", repl_env) if !empty(argv()) diff --git a/wasm/step6_file.wam b/wasm/step6_file.wam index 373f6efc..e6afbb4a 100644 --- a/wasm/step6_file.wam +++ b/wasm/step6_file.wam @@ -346,7 +346,7 @@ ;; core.mal: defined using the language itself ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) - ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) + ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" $repl_env)) ;; Command line arguments diff --git a/wasm/step7_quote.wam b/wasm/step7_quote.wam index 41efd529..fdbc2c24 100644 --- a/wasm/step7_quote.wam +++ b/wasm/step7_quote.wam @@ -408,7 +408,7 @@ ;; core.mal: defined using the language itself ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) - ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) + ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" $repl_env)) ;; Command line arguments diff --git a/wasm/step8_macros.wam b/wasm/step8_macros.wam index 3c5efaa1..20f7059c 100644 --- a/wasm/step8_macros.wam +++ b/wasm/step8_macros.wam @@ -491,7 +491,7 @@ ;; core.mal: defined using the language itself ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) - ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) + ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" $repl_env)) ($RELEASE ($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)))))))" $repl_env)) diff --git a/wasm/step9_try.wam b/wasm/step9_try.wam index b70afb1e..11900603 100644 --- a/wasm/step9_try.wam +++ b/wasm/step9_try.wam @@ -538,7 +538,7 @@ ;; core.mal: defined using the language itself ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) - ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) + ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" $repl_env)) ($RELEASE ($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)))))))" $repl_env)) diff --git a/wasm/stepA_mal.wam b/wasm/stepA_mal.wam index 3caff191..a8866a2a 100644 --- a/wasm/stepA_mal.wam +++ b/wasm/stepA_mal.wam @@ -539,7 +539,7 @@ ;; core.mal: defined using the language itself ($RELEASE ($RE "(def! *host-language* \"WebAssembly\")" $repl_env)) ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) - ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) + ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))" $repl_env)) ($RELEASE ($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)))))))" $repl_env)) ;; Command line arguments diff --git a/yorick/step6_file.i b/yorick/step6_file.i index 70dfe901..d1be3a43 100644 --- a/yorick/step6_file.i +++ b/yorick/step6_file.i @@ -166,7 +166,7 @@ func main(void) // core.mal: defined using the language itself RE, "(def! not (fn* (a) (if a false true)))", repl_env - RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env + RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", repl_env if (numberof(command_line_args) > 0) { RE, "(load-file \"" + command_line_args(1) + "\")", repl_env diff --git a/yorick/step7_quote.i b/yorick/step7_quote.i index bf9cbd1a..3d8d1aa9 100644 --- a/yorick/step7_quote.i +++ b/yorick/step7_quote.i @@ -191,7 +191,7 @@ func main(void) // core.mal: defined using the language itself RE, "(def! not (fn* (a) (if a false true)))", repl_env - RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env + RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", repl_env if (numberof(command_line_args) > 0) { RE, "(load-file \"" + command_line_args(1) + "\")", repl_env diff --git a/yorick/step8_macros.i b/yorick/step8_macros.i index cf77d268..9472ec3e 100644 --- a/yorick/step8_macros.i +++ b/yorick/step8_macros.i @@ -225,7 +225,7 @@ func main(void) // core.mal: defined using the language itself RE, "(def! not (fn* (a) (if a false true)))", repl_env - RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env + RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", repl_env 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)))))))", repl_env if (numberof(command_line_args) > 0) { diff --git a/yorick/step9_try.i b/yorick/step9_try.i index b0899741..0013b069 100644 --- a/yorick/step9_try.i +++ b/yorick/step9_try.i @@ -239,7 +239,7 @@ func main(void) // core.mal: defined using the language itself RE, "(def! not (fn* (a) (if a false true)))", repl_env - RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env + RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", repl_env 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)))))))", repl_env if (numberof(command_line_args) > 0) { diff --git a/yorick/stepA_mal.i b/yorick/stepA_mal.i index ea5c2b32..af272d01 100644 --- a/yorick/stepA_mal.i +++ b/yorick/stepA_mal.i @@ -240,7 +240,7 @@ func main(void) // core.mal: defined using the language itself RE, "(def! *host-language* \"yorick\")", repl_env RE, "(def! not (fn* (a) (if a false true)))", repl_env - RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env + RE, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))", repl_env 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)))))))", repl_env if (numberof(command_line_args) > 0) {