edu.iu.cnets.klatsch.lang
Class VClosure
java.lang.Object
edu.iu.cnets.klatsch.lang.Value
edu.iu.cnets.klatsch.lang.VClosure
- All Implemented Interfaces:
- Callable
public class VClosure
- extends Value
- implements Callable
This value represents a closure, a user-defined procedure that captures any free
variables and can be invoked.
Method Summary |
Value |
apply(Value... args)
Invokes the procedure with the given values as parameters. |
Value |
method_stream(Value... args)
stream() : Turns this zero-argument closure into a (infinite) stream. |
java.lang.String |
toString()
Returns a string representation of the closure. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
idList
java.lang.String[] idList
bodyExp
Expression bodyExp
env
Runtime env
VClosure
public VClosure(java.lang.String[] idList,
Expression bodyExp,
Runtime env)
- Initializes a new closure.
- Parameters:
idList
- the names of the formal parametersbodyExp
- the body of the procedureenv
- the captured environment
apply
public Value apply(Value... args)
throws EvaluationException
- Invokes the procedure with the given values as parameters.
- Specified by:
apply
in interface Callable
- Parameters:
args
- the argument values
- Returns:
- the procedure result
- Throws:
EvaluationException
- if the procedure call fails
toString
public java.lang.String toString()
- Returns a string representation of the closure.
- Specified by:
toString
in class Value
- Returns:
- the string
method_stream
public Value method_stream(Value... args)
throws EvaluationException
- stream() : Turns this zero-argument closure into a (infinite) stream.
- Throws:
EvaluationException