R-alpha: patch for return

Gregory R. Warnes (warnes@biostat.washington.edu)
Sat, 28 Sep 1996 10:56:16 -0700 (PDT)


Date: Sat, 28 Sep 1996 10:56:16 -0700 (PDT)
From: "Gregory R. Warnes" <warnes@biostat.washington.edu>
To: r-testers <r-testers@stat.math.ethz.ch>
Subject: R-alpha: patch for return


Attached is a patch that enables the R return() function to take a list 
of parameters to return as a list.  Before:

> test _ function(x,y) return(a=x,b=y)
> test(1,2)
[1] 1
> 

with the attached patch, as in S:

> test _ function(x,y) return(a=x,b=y)
> test(1,2)
$a
[1] 1

$b
[1] 2

>

Greg

-------------------------------------------------------------------------------
    Gregory R. Warnes          | It is high time that the ideal of success
warnes@biostat.washington.edu  |  be replaced by the ideal of service.
                               |                       Albert Einstein
-------------------------------------------------------------------------------
///////////////////////////PATCH STARTS HERE/////////////////////////////////
--- R.orig/src/main/eval.c      Wed Sep 11 19:46:50 1996
+++ src/main/eval.c     Sat Sep 28 10:45:57 1996
@@ -528,10 +528,18 @@
 
 SEXP do_return(SEXP call, SEXP op, SEXP args, SEXP rho)
 {
+        int counter;
        SEXP s;
-       s = eval(CAR(args), rho);
+
+       if (length(args)==1)
+         s = eval(CAR(args), rho);
+       else
+         s = do_makelist(call, op, args, rho);
+         
        /* R_Visible = 1; */
+
        findcontext(CTXT_RETURN, s);
+
        /*NOTREACHED*/
 }

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-