[uim-commit] r2362 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Sun Dec 4 07:41:47 PST 2005


Author: yamaken
Date: 2005-12-04 07:41:39 -0800 (Sun, 04 Dec 2005)
New Revision: 2362

Modified:
   branches/r5rs/sigscheme/eval.c
Log:
* sigscheme/eval.c
  - (ScmExp_if):
    * Add strict syntax check. The test in test-exp.scm has been passed
    * Make efficient


Modified: branches/r5rs/sigscheme/eval.c
===================================================================
--- branches/r5rs/sigscheme/eval.c	2005-12-04 15:29:38 UTC (rev 2361)
+++ branches/r5rs/sigscheme/eval.c	2005-12-04 15:41:39 UTC (rev 2362)
@@ -711,7 +711,7 @@
 ScmObj ScmExp_if(ScmObj test, ScmObj conseq, ScmObj rest, ScmEvalState *eval_state)
 {
     ScmObj env = eval_state->env;
-    ScmObj alt = SCM_INVALID;
+    ScmObj alt;
     DECLARE_FUNCTION("if", SyntaxVariadicTailRec2);
 
     /*========================================================================
@@ -719,12 +719,21 @@
       (if <test> <consequent> <alternate>)
     ========================================================================*/
 
-    if (NFALSEP(EVAL(test, env)))
+    if (NFALSEP(EVAL(test, env))) {
+#if SCM_STRICT_ARGCHECK
+        POP_ARG(rest);
+        ASSERT_NO_MORE_ARG(rest);
+#endif
         return conseq;
-    else {
-        alt = POP_ARG(rest);
+    } else {
+        /* does not use POP_ARG() for efficiency since 'if' syntax is
+           frequently used */
+        alt = (CONSP(rest)) ? CAR(rest) : SCM_UNDEF;
+#if SCM_STRICT_ARGCHECK
+        POP_ARG(rest);
         ASSERT_NO_MORE_ARG(rest);
-        return VALIDP(alt) ? alt : SCM_UNDEF;
+#endif
+        return alt;
     }
 }
 



More information about the uim-commit mailing list