edu.iu.cnets.klatsch.lang
Class VClosure

java.lang.Object
  extended by edu.iu.cnets.klatsch.lang.Value
      extended by 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.


Field Summary
(package private)  Expression bodyExp
           
(package private)  Runtime env
           
(package private)  java.lang.String[] idList
           
 
Constructor Summary
VClosure(java.lang.String[] idList, Expression bodyExp, Runtime env)
          Initializes a new closure.
 
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 edu.iu.cnets.klatsch.lang.Value
require, requireCount, requireType, toJson
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

idList

java.lang.String[] idList

bodyExp

Expression bodyExp

env

Runtime env
Constructor Detail

VClosure

public VClosure(java.lang.String[] idList,
                Expression bodyExp,
                Runtime env)
Initializes a new closure.

Parameters:
idList - the names of the formal parameters
bodyExp - the body of the procedure
env - the captured environment
Method Detail

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