ix.util.lisp
Class Interpreter.AbstractFunction

java.lang.Object
  extended by ix.util.lisp.Interpreter.AbstractFunction
All Implemented Interfaces:
Interpreter.Function
Direct Known Subclasses:
Interpreter.Closure, Interpreter.JFunction
Enclosing class:
Interpreter

public abstract static class Interpreter.AbstractFunction
extends java.lang.Object
implements Interpreter.Function

An implementation of Function that supplies some utility methods and implements part of the interface.


Field Summary
 
Fields inherited from interface ix.util.lisp.Interpreter.Function
ANY_ARITY
 
Constructor Summary
Interpreter.AbstractFunction()
           
 
Method Summary
 void checkArity(int numberOfArgs)
          Checks whether this function can accept the indicated number of arguments.
protected
<T> T
mustBe(java.lang.Class<T> c, java.lang.Object obj)
          Returns an object if it is an instance of the specified class, but throws a ClassCastException if it isn't.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ix.util.lisp.Interpreter.Function
applyTo, getArity
 

Constructor Detail

Interpreter.AbstractFunction

public Interpreter.AbstractFunction()
Method Detail

checkArity

public void checkArity(int numberOfArgs)
Description copied from interface: Interpreter.Function
Checks whether this function can accept the indicated number of arguments.

Specified by:
checkArity in interface Interpreter.Function

mustBe

protected <T> T mustBe(java.lang.Class<T> c,
                       java.lang.Object obj)
Returns an object if it is an instance of the specified class, but throws a ClassCastException if it isn't. This allows us to provide a more infomative error message than if we'd just cast the object to the desired class.