Package convex.core.lang
Class AFn<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.lang.AFn<T>
- Type Parameters:
T
- Return type of functions.
- All Implemented Interfaces:
IValidated
,IWriteable
,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
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte
getTag()
Gets the tag byte for this cell.getType()
Gets the most specific known runtime Type for this Cell.abstract boolean
hasArity(int arity)
Tests if this function supports the given arity.Invoke this function in the given context.boolean
Returns true if this object represents a first class CVM Value.boolean
supportsArgs(ACell[] args)
Tests if this function supports the given argument list By default, checks if the function supports the given arity only.updateRefs(IRefFunction func)
Updates all Refs in this object using the given function.Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, encode, encodeRaw, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, hashCode, isCanonical, isEmbedded, mark, mark, toCanonical, toString, validate, validateCell, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
AFn
public AFn()
-
-
Method Details
-
invoke
Description copied from interface:IFn
Invoke this function in the given context. -
updateRefs
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. 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 classACell
- Parameters:
func
- Ref update function- Returns:
- Cell with updated Refs
-
getType
Description copied from class:ACell
Gets the most specific known runtime Type for this Cell. -
supportsArgs
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 object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures- Specified by:
isCVMValue
in classACell
- 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 written as the first byte of the Cell's Encoding
-