objpascal, r: Support catchless try*.
authorJoel Martin <github@martintribe.org>
Wed, 27 Feb 2019 23:06:14 +0000 (17:06 -0600)
committerJoel Martin <github@martintribe.org>
Wed, 27 Feb 2019 23:06:14 +0000 (17:06 -0600)
objpascal/step9_try.pas
objpascal/stepA_mal.pas
r/step8_macros.r
r/step9_try.r
r/stepA_mal.r

index 7df833d..d8c5960 100644 (file)
@@ -215,6 +215,8 @@ begin
         except
             On E : Exception do
             begin
+                if Length(Arr) < 3 then
+                    raise;
                 SetLength(Err, 1);
                 if E.ClassType = TMalException then
                     Err[0] := (E as TMalException).Val
index bf5afdf..1e8762e 100644 (file)
@@ -215,6 +215,8 @@ begin
         except
             On E : Exception do
             begin
+                if Length(Arr) < 3 then
+                    raise;
                 SetLength(Err, 1);
                 if E.ClassType = TMalException then
                     Err[0] := (E as TMalException).Val
index 012aa7c..d8d3ba1 100644 (file)
@@ -75,9 +75,8 @@ EVAL <- function(ast, env) {
     repeat {
 
     #cat("EVAL: ", .pr_str(ast,TRUE), "\n", sep="")
-    if (!.list_q(ast)) {
-        return(eval_ast(ast, env))
-    }
+    if (!.list_q(ast)) { return(eval_ast(ast, env)) }
+    if (length(ast) == 0) { return(ast) }
 
     # apply list
     ast <- macroexpand(ast, env)
index 2575baa..049d660 100644 (file)
@@ -75,9 +75,8 @@ EVAL <- function(ast, env) {
     repeat {
 
     #cat("EVAL: ", .pr_str(ast,TRUE), "\n", sep="")
-    if (!.list_q(ast)) {
-        return(eval_ast(ast, env))
-    }
+    if (!.list_q(ast)) { return(eval_ast(ast, env)) }
+    if (length(ast) == 0) { return(ast) }
 
     # apply list
     ast <- macroexpand(ast, env)
@@ -122,7 +121,7 @@ EVAL <- function(ast, env) {
                                          new.list(a2[[2]]),
                                          new.list(edata$exc))))
         } else {
-            throw(err)
+            throw(edata$exc)
         }
     } else if (a0sym == "do") {
         eval_ast(slice(ast,2,length(ast)-1), env)
index ecdb89c..edf41de 100644 (file)
@@ -75,9 +75,8 @@ EVAL <- function(ast, env) {
     repeat {
 
     #cat("EVAL: ", .pr_str(ast,TRUE), "\n", sep="")
-    if (!.list_q(ast)) {
-        return(eval_ast(ast, env))
-    }
+    if (!.list_q(ast)) { return(eval_ast(ast, env)) }
+    if (length(ast) == 0) { return(ast) }
 
     # apply list
     ast <- macroexpand(ast, env)
@@ -122,7 +121,7 @@ EVAL <- function(ast, env) {
                                          new.list(a2[[2]]),
                                          new.list(edata$exc))))
         } else {
-            throw(err)
+            throw(edata$exc)
         }
     } else if (a0sym == "do") {
         eval_ast(slice(ast,2,length(ast)-1), env)