// EVAL
macro_Q = { ast, env ->
if (types.list_Q(ast) &&
+ ast.size() > 0 &&
ast[0].class == MalSymbol &&
env.find(ast[0])) {
def obj = env.get(ast[0])
ast = macroexpand(ast, env)
if (! types.list_Q(ast)) return eval_ast(ast, env)
+ if (ast.size() == 0) return ast
switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
// 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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
if (this.args.size() > 0) {
try {
println REP(line)
} catch(MalException ex) {
- println "Error: ${ex.message}"
+ println "Error: ${printer.pr_str(ex.obj, true)}"
} catch(StackOverflowError ex) {
println "Error: ${ex}"
} catch(ex) {