[armedbear-cvs] r12589 - trunk/abcl/src/org/armedbear/lisp

Ville Voutilainen vvoutilainen at common-lisp.net
Sat Apr 10 17:52:45 UTC 2010


Author: vvoutilainen
Date: Sat Apr 10 13:52:44 2010
New Revision: 12589

Log:
Make cadr/cddr/caddr final.


Modified:
   trunk/abcl/src/org/armedbear/lisp/Cons.java
   trunk/abcl/src/org/armedbear/lisp/LispObject.java
   trunk/abcl/src/org/armedbear/lisp/Nil.java

Modified: trunk/abcl/src/org/armedbear/lisp/Cons.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Cons.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Cons.java	Sat Apr 10 13:52:44 2010
@@ -134,24 +134,6 @@
   }
 
   @Override
-  public final LispObject cadr()
-  {
-    return cdr.car();
-  }
-
-  @Override
-  public final LispObject cddr()
-  {
-    return cdr.cdr();
-  }
-
-  @Override
-  public final LispObject caddr()
-  {
-    return cdr.cadr();
-  }
-
-  @Override
   public LispObject nthcdr(int n)
   {
     if (n < 0)

Modified: trunk/abcl/src/org/armedbear/lisp/LispObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispObject.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispObject.java	Sat Apr 10 13:52:44 2010
@@ -195,19 +195,31 @@
     return type_error(this, Symbol.CONS);
   }
 
-  public LispObject cadr()
+  public final LispObject cadr()
   {
-    return type_error(this, Symbol.LIST);
+    LispObject tail = cdr();
+    if (!(tail instanceof Nil)) {
+        return tail.car();
+    } else 
+        return NIL;
   }
 
-  public LispObject cddr()
+  public final LispObject cddr()
   {
-    return type_error(this, Symbol.LIST);
+    LispObject tail = cdr();
+    if (!(tail instanceof Nil)) {
+        return tail.cdr();
+    } else 
+        return NIL;
   }
 
-  public LispObject caddr()
+  public final LispObject caddr()
   {
-    return type_error(this, Symbol.LIST);
+    LispObject tail = cddr();
+    if (!(tail instanceof Nil)) {
+        return tail.car();
+    } else 
+        return NIL;
   }
 
   public LispObject nthcdr(int n)

Modified: trunk/abcl/src/org/armedbear/lisp/Nil.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Nil.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Nil.java	Sat Apr 10 13:52:44 2010
@@ -107,24 +107,6 @@
     }
 
     @Override
-    public final LispObject cadr()
-    {
-        return this;
-    }
-
-    @Override
-    public final LispObject cddr()
-    {
-        return this;
-    }
-
-    @Override
-    public final LispObject caddr()
-    {
-        return this;
-    }
-
-    @Override
     public LispObject nthcdr(int n)
     {
         if (n < 0)




More information about the armedbear-cvs mailing list