Class AFn<T extends ACell>

Type Parameters:
T - Return type of functions.
All Implemented Interfaces:
IValidated, IWriteable, IFn<T>
Direct Known Subclasses:
AClosure, ADataFn, CoreFn

public abstract class AFn<T extends ACell> extends ACell implements IFn<T>
Base class for functions expressed as values "You know what's web-scale? The Web. And you know what it is? Dynamically typed." - Stuart Halloway
  • Constructor Details

    • AFn

      public AFn()
  • Method Details

    • invoke

      public abstract Context invoke(Context context, ACell[] args)
      Description copied from interface: IFn
      Invoke this function in the given context.
      Specified by:
      invoke in interface IFn<T extends ACell>
      Parameters:
      context - Context in which the function is to be executed
      args - Arguments to the function
      Returns:
      Context containing result of function invocation, or an exceptional value
    • updateRefs

      public abstract AFn<T> updateRefs(IRefFunction func)
      Description copied from class: ACell
      Updates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.
      Overrides:
      updateRefs in class ACell
      Parameters:
      func - Ref update function
      Returns:
      Cell with updated Refs
    • getType

      public final AType getType()
      Description copied from class: ACell
      Gets the most specific known runtime Type for this Cell.
      Overrides:
      getType in class ACell
      Returns:
      The Type of this Call
    • supportsArgs

      public boolean supportsArgs(ACell[] args)
      Tests if this function supports the given argument list By default, checks if the function supports the given arity only. TODO: intention is to override this to include dynamic type checks etc.
      Parameters:
      args - Array of arguments
      Returns:
      true if function supports the specified args array
    • hasArity

      public abstract boolean hasArity(int arity)
      Tests if this function supports the given arity.
      Parameters:
      arity - Arity to check
      Returns:
      true if function supports the given arity, false otherwise
    • isCVMValue

      public boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this Cell represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false, pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures
      Specified by:
      isCVMValue in class ACell
      Returns:
      true if the object is a CVM Value, false otherwise
    • getTag

      public byte getTag()
      Description copied from class: ACell
      Gets the tag byte for this cell. The tag byte is always equal to the first byte of the Cell's canonical Encoding, and is sufficient to distinguish how to read the rest of the encoding.
      Specified by:
      getTag in class ACell
      Returns:
      Tag byte for this Cell