[armedbear-cvs] r11310 - trunk/j/src/org/armedbear/lisp

ehuelsmann at common-lisp.net ehuelsmann at common-lisp.net
Fri Sep 12 21:40:40 UTC 2008


Author: ehuelsmann
Date: Fri Sep 12 17:40:40 2008
New Revision: 11310

Modified:
   trunk/j/src/org/armedbear/lisp/SpecialOperators.java
Log:
Fold 2 code paths which essentially differ only by 1 conditional in _let().

Modified: trunk/j/src/org/armedbear/lisp/SpecialOperators.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/SpecialOperators.java	(original)
+++ trunk/j/src/org/armedbear/lisp/SpecialOperators.java	Fri Sep 12 17:40:40 2008
@@ -132,119 +132,51 @@
               break;
           }
         Environment ext = new Environment(env);
-        if (sequential)
+        while (varList != NIL)
           {
-            // LET*
-            while (varList != NIL)
+            final Symbol symbol;
+            LispObject value;
+            LispObject obj = varList.car();
+            if (obj instanceof Cons)
               {
-                final Symbol symbol;
-                LispObject value;
-                LispObject obj = varList.car();
-                if (obj instanceof Cons)
-                  {
-                    if (obj.length() > 2)
-                      return error(new LispError("The LET* binding specification " +
-                                                  obj.writeToString() +
-                                                  " is invalid."));
-                    try
-                      {
-                        symbol = (Symbol) ((Cons)obj).car;
-                      }
-                    catch (ClassCastException e)
-                      {
-                        return type_error(((Cons)obj).car, Symbol.SYMBOL);
-                      }
-                    value = eval(obj.cadr(), ext, thread);
-                  }
-                else
+                if (obj.length() > 2)
+                  return error(new LispError("The LET* binding specification " +
+                                              obj.writeToString() +
+                                              " is invalid."));
+                try
                   {
-                    try
-                      {
-                        symbol = (Symbol) obj;
-                      }
-                    catch (ClassCastException e)
-                      {
-                        return type_error(obj, Symbol.SYMBOL);
-                      }
-                    value = NIL;
+                    symbol = (Symbol) ((Cons)obj).car;
                   }
-                if (specials != NIL && memq(symbol, specials))
+                catch (ClassCastException e)
                   {
-                    thread.bindSpecial(symbol, value);
-                    ext.declareSpecial(symbol);
+                    return type_error(((Cons)obj).car, Symbol.SYMBOL);
                   }
-                else if (symbol.isSpecialVariable())
-                  {
-                    thread.bindSpecial(symbol, value);
-                  }
-                else
-                  ext.bind(symbol, value);
-                varList = ((Cons)varList).cdr;
-              }
-          }
-        else
-          {
-            // LET
-            final int length = varList.length();
-            LispObject[] vals = new LispObject[length];
-            for (int i = 0; i < length; i++)
-              {
-                LispObject obj = ((Cons)varList).car;
-                if (obj instanceof Cons)
-                  {
-                    if (obj.length() > 2)
-                      return error(new LispError("The LET binding specification " +
-                                                  obj.writeToString() +
-                                                  " is invalid."));
-                    vals[i] = eval(obj.cadr(), env, thread);
-                  }
-                else
-                  vals[i] = NIL;
-                varList = ((Cons)varList).cdr;
+                value = eval(obj.cadr(), sequential ? ext : env, thread);
               }
-            varList = args.car();
-            int i = 0;
-            while (varList != NIL)
-              {
-                final Symbol symbol;
-                LispObject obj = varList.car();
-                if (obj instanceof Cons)
-                  {
-                    try
-                      {
-                        symbol = (Symbol) ((Cons)obj).car;
-                      }
-                    catch (ClassCastException e)
-                      {
-                        return type_error(((Cons)obj).car, Symbol.SYMBOL);
-                      }
-                  }
-                else
-                  {
-                    try
-                      {
-                        symbol = (Symbol) obj;
-                      }
-                    catch (ClassCastException e)
-                      {
-                        return type_error(obj, Symbol.SYMBOL);
-                      }
-                  }
-                LispObject value = vals[i];
-                if (specials != NIL && memq(symbol, specials))
+            else
+              {
+                try
                   {
-                    thread.bindSpecial(symbol, value);
-                    ext.declareSpecial(symbol);
+                    symbol = (Symbol) obj;
                   }
-                else if (symbol.isSpecialVariable())
+                catch (ClassCastException e)
                   {
-                    thread.bindSpecial(symbol, value);
+                    return type_error(obj, Symbol.SYMBOL);
                   }
-                else
-                  ext.bind(symbol, value);
-                varList = ((Cons)varList).cdr;
-                ++i;
+                value = NIL;
               }
+            if (specials != NIL && memq(symbol, specials))
+              {
+                thread.bindSpecial(symbol, value);
+                ext.declareSpecial(symbol);
+              }
+            else if (symbol.isSpecialVariable())
+              {
+                thread.bindSpecial(symbol, value);
+              }
+            else
+              ext.bind(symbol, value);
+            varList = ((Cons)varList).cdr;
           }
         // Make sure free special declarations are visible in the body.
         // "The scope of free declarations specifically does not include



More information about the armedbear-cvs mailing list