org.norecess.citkit.environment
Interface IEnvironment<T>

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
Environment, NullEnvironment

public interface IEnvironment<T>
extends java.io.Serializable

Interface for environments. See Environment for a practical implementation. The generic type parameter is the type of the values stored in the environment; the keys must be Symbols.

Author:
Jeremy D. Frens

Method Summary
 void add(ISymbol variable, T value)
          Adds a new variable to the current environment.
 IEnvironment<T> create()
          Creates a nested environment.
 void define(ISymbol variable, T value)
          Defines the variable in the top level environment.
 T get(ISymbol variable)
          Returns the value associated with the specified variable.
 T set(ISymbol variable, T value)
          Changes the value associated with the specified variable.
 

Method Detail

define

void define(ISymbol variable,
            T value)
Defines the variable in the top level environment.

Parameters:
variable - the variable to define.
value - the value to set it to.

add

void add(ISymbol variable,
         T value)
         throws InvalidVariableException
Adds a new variable to the current environment. Presently, this does not check the previous environments to see if this shadows an earlier declaration; if this were implemented, it'd be a warning, not an error.

Parameters:
variable - the new variable to add to the environment.
value - the new value to associate with the new variable.
Throws:
InvalidVariableException - when the variable is already declared in the current scope.

get

T get(ISymbol variable)
      throws InvalidVariableException
Returns the value associated with the specified variable. The variable is searched for in all of the previous scopes.

Parameters:
variable - the variable to search for.
Returns:
the value associated with the variable.
Throws:
InvalidVariableException - when the variable is undeclared (in this or any previous scope).

set

T set(ISymbol variable,
      T value)
      throws InvalidVariableException
Changes the value associated with the specified variable. The variable is searched for in all of the previous scopes; the old value is returned.

Parameters:
variable - the variable to search for.
value - the new value for the variable.
Returns:
the old value associated with the variable.
Throws:
InvalidVariableException - when the variable is undeclared (in this or any previous scope).

create

IEnvironment<T> create()
Creates a nested environment.