Interfaces¶
Basilisp (like Clojure) is defined by interfaces.
All of the built-in data types are implement 0 or more of these Python interfaces and basilisp.core functions typically operate on these interfaces, rather than concrete data types (with some exceptions).
In day-to-day usage, you will not typically need to use these interfaces, but they are nevertheless helpful for understanding the abstractions Basilisp is built upon.
Warning
These interfaces are not considered part of the Basilisp public API and therefore are subject to change at any time without notice. This documentation is intended to help users understand the abstractions that underpin Basilisp.
- class basilisp.lang.interfaces.ILispObject¶
Abstract base class for Lisp objects which would like to customize their
__str__and Python__repr__representation.
- class basilisp.lang.interfaces.IAssociative¶
Bases:
ILookup[K,V],IPersistentCollection[IMapEntry[K,V]]IAssociativetypes support a persistent data structure variant of associative operations.See also
assoc,contains?,find,associative?
- class basilisp.lang.interfaces.IBlockingDeref¶
Bases:
IDeref[T]IBlockingDereftypes are reference container types which may block returning their contained value. The contained value can be fetched with a timeout and default viaderef.See also
- class basilisp.lang.interfaces.ICounted¶
-
ICountedis a marker interface for types can produce their length in constant time.All the builtin collections are
ICounted, except Lists whose length is determined by counting all the elements in the list in linear time.See also
- class basilisp.lang.interfaces.IDeref¶
-
IDereftypes are reference container types which return their contained value viaderef.See also
- class basilisp.lang.interfaces.IEvolveableCollection¶
Bases:
Generic[T_tcoll]IEvolveableCollectiontypes support creating transient variants of persistent data structures which can be modified efficiently and then returned back into persistent data structures once modification is complete.See also
- abstract to_transient() T_tcoll¶
- exception basilisp.lang.interfaces.IExceptionInfo¶
Bases:
Exception,Generic[T_ExceptionInfo],ABCIExceptionInfotypes are exception types which contain an optionalIPersistentMapdata element of contextual information about the thrown exception.See also
- abstract property data: T_ExceptionInfo¶
- class basilisp.lang.interfaces.IIndexed¶
Bases:
ICounted,Generic[V],ABCIIndexedis an interface for types can be accessed by index.Of the builtin collections, only Vectors are
IIndexed.IIndexedtypes respondTrueto theindexed?predicate.- NTH_SENTINEL = <object object>¶
- class basilisp.lang.interfaces.ILookup¶
-
ILookuptypes allow accessing contained values by a key or index.See also
- class basilisp.lang.interfaces.IMapEntry¶
-
IMapEntryvalues are producedseqing over anyIAssociative(such as a Basilisp map).See also
key,val,map-entry?- abstract property key: K¶
- abstract property value: V¶
- class basilisp.lang.interfaces.IMeta¶
Bases:
ABCIMetatypes can optionally include a map of metadata.Persistent data types metadata cannot be mutated, but many of these data types also implement
IWithMetawhich allows creating a copy of the structure with new metadata.See also
- abstract property meta: IPersistentMap | None¶
- class basilisp.lang.interfaces.INamed¶
Bases:
ABCINamedinstances are symbolic identifiers with a name and optional namespace.
- class basilisp.lang.interfaces.IPending¶
Bases:
ABCIPendingtypes are types which may represent deferred computations such as a future or promise.
- class basilisp.lang.interfaces.IPersistentCollection¶
Bases:
ISeqable[T]IPersistentCollectiontypes support both fetching empty variants of an existing persistent collection and creating a new collection with additional members.
- class basilisp.lang.interfaces.IPersistentList¶
Bases:
ISequential,IPersistentStack[T]IPersistentListis a marker interface for a singly-linked list.
- class basilisp.lang.interfaces.IPersistentMap¶
Bases:
ICounted,Mapping[K,V],IAssociative[K,V]IPersistentMaptypes support creating and modifying persistent maps.- abstract cons(*elems: IMapEntry[K, V] | IPersistentMap[K, V] | None) Self¶
- class basilisp.lang.interfaces.IPersistentSet¶
Bases:
AbstractSet[T],ICounted,IPersistentCollection[T]IPersistentSettypes support creating and modifying persistent sets.
- class basilisp.lang.interfaces.IPersistentStack¶
Bases:
IPersistentCollection[T]IPersistentStacktypes support a persistent data structure variant of classical stack operations.
- class basilisp.lang.interfaces.IPersistentVector¶
Bases:
Sequence[T],IAssociative[int,T],IIndexed,IReversible[T],ISequential,IPersistentStack[T]IPersistentVectortypes support creating and modifying persistent vectors.See also
- class basilisp.lang.interfaces.IProxy¶
Bases:
ABCIProxyis a marker interface for proxy types.All types created by
proxyare automatically marked withIProxy.See also
Proxies,
proxy,proxy-mappings,proxy-super,construct-proxy,init-proxy,update-proxy,get-proxy-class
- class basilisp.lang.interfaces.IRecord¶
Bases:
LispObjectIRecordis a marker interface for typesdef‘ed bydefrecordforms.All types created by
defrecordare automatically marked withIRecord.See also
- abstract classmethod create(m: IPersistentMap) IRecord¶
Class method constructor from an
IPersistentMapinstance.
- class basilisp.lang.interfaces.IReduce¶
Bases:
ABCIReducetypes define custom implementations ofreduce.Only vectors are
IReduceby default, providing faster iteration than relying onseq.See also
- abstract reduce(f: ReduceFunction[T, V_contra]) T¶
- abstract reduce(f: ReduceFunction[T, V_contra], init: T) T
- class basilisp.lang.interfaces.IReduceKV¶
Bases:
ABCIReduceKVtypes define custom implementations ofreduce-kv.Both vectors and maps are
IReduceKVby default, providing faster iteration than relying onseq. Maps iterate over the key-value pairs as expected, and vectors iterate over the index-item pairs of the vector.See also
- class basilisp.lang.interfaces.IRef¶
Bases:
IDeref[T]IReftypes are mutable reference containers which support validation of the contained value and watchers which are notified when the contained value changes.See also
- abstract remove_watch(k: Hashable) IReference¶
- class basilisp.lang.interfaces.IReference¶
Bases:
IMetaIReferencetypes are mutable reference containers which allow mutation of the associated metadata.See also
- abstract alter_meta(f: Callable[[...], IPersistentMap | None], *args) IPersistentMap | None¶
- abstract reset_meta(meta: IPersistentMap | None) IPersistentMap | None¶
- class basilisp.lang.interfaces.IReversible¶
Bases:
Generic[T]IReversibletypes can produce a sequences of their elements in reverse in constant time.Of the builtin collections, only Vectors are
IReversible.See also
- class basilisp.lang.interfaces.ISeq¶
Bases:
LispObject,IPersistentCollection[T]ISeqtypes represent a potentially infinite sequence of elements.
- class basilisp.lang.interfaces.ISeqable¶
Bases:
Iterable[T]ISeqabletypes can produce sequences of their elements, but are notISeq.All the builtin collections are
ISeqable, except Lists which directly implementISeq.
- class basilisp.lang.interfaces.ISequential¶
Bases:
ABCISequentialis a marker interface for sequential types.Lists and Vectors are both considered
ISequential.See also
- class basilisp.lang.interfaces.ITransientAssociative¶
Bases:
ILookup[K,V],ITransientCollection[IMapEntry[K,V]]ITransientAssociativetypes are the transient counterpart ofIAssociativetypes.
- class basilisp.lang.interfaces.ITransientCollection¶
Bases:
Generic[T]ITransientCollectiontypes support efficient modification of otherwise persistent data structures.See also
- abstract cons_transient(*elems: T) T_tcoll¶
- abstract to_persistent() IPersistentCollection[T]¶
- class basilisp.lang.interfaces.ITransientMap¶
Bases:
ICounted,ITransientAssociative[K,V]ITransientMaptypes are the transient counterpart ofIPersistentMaptypes.See also
- abstract cons_transient(*elems: IMapEntry[K, V] | IPersistentMap[K, V] | None) Self¶
- class basilisp.lang.interfaces.ITransientSet¶
Bases:
ICounted,ITransientCollection[T]ITransientSettypes are the transient counterpart ofIPersistentSettypes.See also
- class basilisp.lang.interfaces.ITransientVector¶
Bases:
ITransientAssociative[int,T],IIndexedITransientVectortypes are the transient counterpart ofIPersistentVectortypes.- abstract assoc_transient(*kvs) T_tvec¶
- abstract cons_transient(*elems: T) T_tvec¶
- abstract pop_transient() T_tvec¶