view src/clojure/lang/AFunction.java @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
line wrap: on
line source
1 /**
2 * Copyright (c) Rich Hickey. All rights reserved.
3 * The use and distribution terms for this software are covered by the
4 * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5 * which can be found in the file epl-v10.html at the root of this distribution.
6 * By using this software in any fashion, you are agreeing to be bound by
7 * the terms of this license.
8 * You must not remove this notice, or any other, from this software.
9 **/
11 /* rich Dec 16, 2008 */
13 package clojure.lang;
15 import java.io.Serializable;
16 import java.util.Comparator;
18 public abstract class AFunction extends AFn implements IObj, Comparator, Fn, Serializable {
20 public volatile MethodImplCache __methodImplCache;
22 public int compare(Object o1, Object o2){
23 try
24 {
25 Object o = invoke(o1, o2);
27 if(o instanceof Boolean)
28 {
29 if(RT.booleanCast(o))
30 return -1;
31 return RT.booleanCast(invoke(o2,o1))? 1 : 0;
32 }
34 Number n = (Number) o;
35 return n.intValue();
36 }
37 catch(Exception e)
38 {
39 throw new RuntimeException(e);
40 }
41 }
42 }