orc.runtime.values
Class Value

java.lang.Object
  extended by orc.runtime.values.Value
Direct Known Subclasses:
Closure, Field, ListValue, OptionValue, Site

public abstract class Value
extends java.lang.Object

A fully evaluated Orc value. This includes sites, tuples of fully evaluated values, and native Java values. However, it does not include unbound or partially-bound values, which are instead in the broader category of Futures.

Author:
dkitchin

Field Summary
static Callable futureNotReady
          Distinguished value used to indicate that a forced value is not ready.
 
Constructor Summary
Value()
           
 
Method Summary
<E> E
accept(Visitor<E> visitor)
           
static java.lang.Object forceArg(java.lang.Object f, Token t)
          Force a value (which may be a future) in argument position.
static Callable forceCall(java.lang.Object f, Token t)
          Force a value (which may be a future) in call position.
 boolean isNone()
           
 boolean isSome()
          Test whether this value inhabits one of the option or list types.
static Value signal()
          Static function to access the canonical 'unit' value; currently, the signal value is an empty tuple.
 java.lang.Object untag()
          Return the contained value v of an option some(v).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

futureNotReady

public static final Callable futureNotReady
Distinguished value used to indicate that a forced value is not ready. Don't try to use this value in Orc programs. We use this instead of throwing an exception because I suspect it's much faster for the common case.

Constructor Detail

Value

public Value()
Method Detail

forceCall

public static Callable forceCall(java.lang.Object f,
                                 Token t)
                          throws UncallableValueException
Force a value (which may be a future) in call position. If the future is not ready, return futureNotReady and place the token on a waiting list to be reactivated when the future is ready.

The primary reason to distinguish call and argument values is that a closure is allowed to have unforced free values in call position, but not in argument position (lest those unforced free values escape their lexical context).

Throws:
UncallableValueException

forceArg

public static java.lang.Object forceArg(java.lang.Object f,
                                        Token t)
Force a value (which may be a future) in argument position. If the future is not ready, return futureNotReady and place the token on a waiting list to be reactivated when the future is ready.


signal

public static Value signal()
Static function to access the canonical 'unit' value; currently, the signal value is an empty tuple.


isSome

public boolean isSome()
Test whether this value inhabits one of the option or list types.


isNone

public boolean isNone()

untag

public java.lang.Object untag()
Return the contained value v of an option some(v). This method must throw an exception iff isSome() returns false.


accept

public <E> E accept(Visitor<E> visitor)