silk
Class Closure

java.lang.Object
silk.Procedure
silk.Closure
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Runnable
- Direct Known Subclasses:
- Macro
- public class Closure
- extends Procedure
- implements java.lang.Cloneable
A closure is a user-defined procedure. It is "closed" over the
environment in which it was created. To apply the procedure, bind
the parameters to the passed in variables, and evaluate the body.
| Methods inherited from class silk.Procedure |
apply, makeArgArray, makeArgArray, nParms, run, setName, throwObject, throwRuntimeException, toStringArgs, tryCatch, tryFinally |
body
java.lang.Object body
env
Environment env
parms
java.lang.Object parms
Closure
public Closure(java.lang.Object parms,
java.lang.Object body,
Environment env)
- Make a closure from a body and the analyze time environment it
was defined in. To create a closure at execute time, use .copy()
computeArgs
private void computeArgs(java.lang.Object parms,
int min)
- Compute minArgs and maxArgs from the parameter list
apply
public java.lang.Object apply(java.lang.Object[] args)
- Apply a closure to a vector of arguments. Do this by creating
a new Environment containing the arguments, and then evaluating the body
of the closure in that new frame.
- Specified by:
apply in class Procedure
copy
public Closure copy(Environment env)
- Make a copy, but with a runtime environment.
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object
- Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method
never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string
concatenation with this object. If the result is
null, string concatenation will instead
use "null".
The default implementation returns
getClass().getName() + "@" +
Integer.toHexString(hashCode()).
- Overrides:
toString in class Procedure