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
]]IAssociative
types support a persistent data structure variant of associative operations.See also
assoc
,contains?
,find
,associative?
- class basilisp.lang.interfaces.IBlockingDeref¶
Bases:
IDeref
[T
]IBlockingDeref
types 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¶
-
ICounted
is 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¶
-
IDeref
types are reference container types which return their contained value viaderef
.See also
- class basilisp.lang.interfaces.IEvolveableCollection¶
Bases:
Generic
[T_tcoll_co
]IEvolveableCollection
types 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_co ¶
- exception basilisp.lang.interfaces.IExceptionInfo¶
Bases:
Exception
,Generic
[T_ExceptionInfo
],ABC
IExceptionInfo
types are exception types which contain an optionalIPersistentMap
data element of contextual information about the thrown exception.See also
- abstract property data: T_ExceptionInfo¶
- class basilisp.lang.interfaces.IIndexed¶
-
IIndexed
is a marker interface for types can be accessed by index.Of the builtin collections, only Vectors are
IIndexed
.IIndexed
types respondTrue
to theindexed?
predicate.See also
- class basilisp.lang.interfaces.ILookup¶
-
ILookup
types allow accessing contained values by a key or index.See also
- class basilisp.lang.interfaces.IMapEntry¶
-
IMapEntry
values are producedseq
ing 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:
ABC
IMeta
types can optionally include a map of metadata.Persistent data types metadata cannot be mutated, but many of these data types also implement
IWithMeta
which allows creating a copy of the structure with new metadata.See also
- abstract property meta: IPersistentMap | None¶
- class basilisp.lang.interfaces.INamed¶
Bases:
ABC
INamed
instances are symbolic identifiers with a name and optional namespace.
- class basilisp.lang.interfaces.IPersistentCollection¶
Bases:
ISeqable
[T
]IPersistentCollection
types support both fetching empty variants of an existing persistent collection and creating a new collection with additional members.- abstract static empty() IPersistentCollection[T] ¶
- class basilisp.lang.interfaces.IPersistentList¶
Bases:
ISequential
,IPersistentStack
[T
]IPersistentList
is a marker interface for a singly-linked list.
- class basilisp.lang.interfaces.IPersistentMap¶
Bases:
ICounted
,Mapping
[K
,V
],IAssociative
[K
,V
]IPersistentMap
types 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
]IPersistentSet
types support creating and modifying persistent sets.
- class basilisp.lang.interfaces.IPersistentStack¶
Bases:
IPersistentCollection
[T
]IPersistentStack
types 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
]IPersistentVector
types support creating and modifying persistent vectors.See also
- class basilisp.lang.interfaces.IRecord¶
Bases:
LispObject
IRecord
is a marker interface for typesdef
‘ed bydefrecord
forms.All types created by
defrecord
are automatically marked withIRecord
.See also
- abstract classmethod create(m: IPersistentMap) IRecord ¶
Class method constructor from an
IPersistentMap
instance.
- class basilisp.lang.interfaces.IRef¶
Bases:
IDeref
[T
]IRef
types 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:
IMeta
IReference
types 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
]IReversible
types 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
]ISeq
types represent a potentially infinite sequence of elements.
- class basilisp.lang.interfaces.ISeqable¶
Bases:
Iterable
[T
]ISeqable
types 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:
ABC
ISequential
is 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
]]ITransientAssociative
types are the transient counterpart ofIAssociative
types.
- class basilisp.lang.interfaces.ITransientCollection¶
Bases:
Generic
[T
]ITransientCollection
types support efficient modification of otherwise persistent data structures.See also
- abstract cons_transient(*elems: T) T_tcoll_co ¶
- abstract to_persistent() IPersistentCollection[T] ¶
- class basilisp.lang.interfaces.ITransientMap¶
Bases:
ICounted
,ITransientAssociative
[K
,V
]ITransientMap
types are the transient counterpart ofIPersistentMap
types.See also
- abstract cons_transient(*elems: IMapEntry[K, V] | IPersistentMap[K, V] | None) Self ¶
- class basilisp.lang.interfaces.ITransientSet¶
Bases:
ICounted
,ITransientCollection
[T
]ITransientSet
types are the transient counterpart ofIPersistentSet
types.See also
- class basilisp.lang.interfaces.ITransientVector¶
Bases:
ITransientAssociative
[int
,T
],IIndexed
ITransientVector
types are the transient counterpart ofIPersistentVector
types.- abstract assoc_transient(*kvs) T_tvec ¶
- abstract cons_transient(*elems: T) T_tvec ¶
- abstract pop_transient() T_tvec ¶