Class AClosure<T extends ACell>

Type Parameters:
T - Return type of function
All Implemented Interfaces:
IValidated, IWriteable, IFn<T>
Direct Known Subclasses:
Fn, MultiFn

public abstract class AClosure<T extends ACell> extends AFn<T>
Abstract base class for functions that can close over a lexical environment.
  • Field Details

    • lexicalEnv

      protected final AVector<ACell> lexicalEnv
      Lexical environment saved for this closure
  • Constructor Details

    • AClosure

      protected AClosure(AVector<ACell> lexicalEnv)
  • Method Details

    • withEnvironment

      public abstract <F extends AClosure<T>> F withEnvironment(AVector<ACell> env)
      Produces an copy of this closure with the specified environment
      Parameters:
      env - New lexical environment to use for this closure
      Returns:
      Closure updated with new lexical environment
    • printInternal

      public abstract void printInternal(StringBuilder sb)
      Print the "internal" representation of a closure e.g. "[x] 1", excluding the 'fn' symbol.
      Parameters:
      sb - StringBuilder to print to