elixir, elm, erlang: Support catchless try*.
authorJoel Martin <github@martintribe.org>
Thu, 28 Feb 2019 23:36:54 +0000 (17:36 -0600)
committerJoel Martin <github@martintribe.org>
Thu, 28 Feb 2019 23:36:54 +0000 (17:36 -0600)
elixir/lib/mix/tasks/step9_try.ex
elixir/lib/mix/tasks/stepA_mal.ex
elm/step9_try.elm
elm/stepA_mal.elm
erlang/src/step9_try.erl
erlang/src/stepA_mal.erl

index 036952a..b1b94c8 100644 (file)
@@ -232,6 +232,9 @@ defmodule Mix.Tasks.Step9Try do
   defp eval_list([{:symbol, "try*"}, try_form, {:list, catch_list, _meta}], env, _) do
     eval_try(try_form, catch_list, env)
   end
+  defp eval_list([{:symbol, "try*"}, try_form], env, _) do
+    eval(try_form, env)
+  end
   defp eval_list([{:symbol, "try*"}, _try_form, _], _env, _) do
     throw({:error, "try* requires a list as the second parameter"})
   end
index af7586e..c827b06 100644 (file)
@@ -251,6 +251,9 @@ defmodule Mix.Tasks.StepAMal do
   defp eval_list([{:symbol, "try*"}, try_form, {:list, catch_list, _meta}], env, _) do
     eval_try(try_form, catch_list, env)
   end
+  defp eval_list([{:symbol, "try*"}, try_form], env, _) do
+    eval(try_form, env)
+  end
   defp eval_list([{:symbol, "try*"}, _try_form, _], _env, _) do
     throw({:error, "try* requires a list as the second parameter"})
   end
index 90e0441..44b3180 100644 (file)
@@ -700,6 +700,8 @@ macroexpand expr =
 evalTry : List MalExpr -> Eval MalExpr
 evalTry args =
     case args of
+        [ body ] ->
+            eval body
         [ body, MalList [ MalSymbol "catch*", MalSymbol sym, handler ] ] ->
             eval body
                 |> Eval.catchError
index 5b28c60..83aed32 100644 (file)
@@ -716,6 +716,8 @@ macroexpand expr =
 evalTry : List MalExpr -> Eval MalExpr
 evalTry args =
     case args of
+        [ body ] ->
+            eval body
         [ body, MalList [ MalSymbol "catch*", MalSymbol sym, handler ] ] ->
             eval body
                 |> Eval.catchError
index 9ca6303..c35da92 100644 (file)
@@ -142,6 +142,8 @@ eval_list({list, [{symbol, "try*"}, A, {list, [{symbol, "catch*"}, B, C], _M1}],
             env:bind(NewEnv, [B], [Reason]),
             eval(C, NewEnv)
     end;
+eval_list({list, [{symbol, "try*"}, AST], _Meta}, Env) ->
+    eval(AST, Env);
 eval_list({list, [{symbol, "try*"}|_], _Meta}, _Env) ->
     error("try*/catch* must be of the form (try* A (catch* B C))");
 eval_list({list, List, Meta}, Env) ->
index f848b91..b60fdf7 100644 (file)
@@ -146,6 +146,8 @@ eval_list({list, [{symbol, "try*"}, A, {list, [{symbol, "catch*"}, B, C], _M1}],
             env:bind(NewEnv, [B], [Reason]),
             eval(C, NewEnv)
     end;
+eval_list({list, [{symbol, "try*"}, AST], _Meta}, Env) ->
+    eval(AST, Env);
 eval_list({list, [{symbol, "try*"}|_], _Meta}, _Env) ->
     error("try*/catch* must be of the form (try* A (catch* B C))");
 eval_list({list, List, Meta}, Env) ->