Types¶
-
type ml_value_t¶
Represents a Minilang value. Every Minilang value must contain this struct at the start.
Type of this value.
-
type ml_type_t¶
Represents a Minilang type.
Although this is not a completely opaque type, avoid creating instances directly and instead use the
ML_TYPE
macro to declare and initialize aml_type_t
.-
const char *Name¶
A short string name for the type, used for the default string conversion and error messages.
-
long (*hash)(ml_value_t*, ml_hash_chain_t*)¶
Function for hashing instances of this type.
-
void (*call)(ml_state_t*, ml_value_t*, int, ml_value_t**)¶
Function for calling instances of this type.
-
ml_value_t *(*deref)(ml_value_t*)¶
Function for dereferencing instances of this type.
-
ml_value_t *(*assign)(ml_value_t*, ml_value_t*)¶
Function for assigning values to instances of this type.
-
ml_value_t *Constructor¶
Minilang function to call when calling this type as a constructor.
-
const char *Name¶
-
ML_TYPE(TYPE, PARENTS, NAME, ...)¶
Declares and initializes a new type.
PARENTS
must be a list of parent types written in parentheses(Type₁, Type₂, ...)
. It is not necessary to includeMLAnyT
(the base type of all types). The list of parent types can be empty.The callback functions are initialized to defaults and should be overridden if required using designated initializers: e.g.
.deref = my_deref
.
-
ML_INTERFACE(TYPE, PARENTS, NAME, ...)¶
Same as
ML_TYPE
for types with empty instances (and thus behave as an interface).
-
ml_value_t MLNil[]¶
The
nil
value.
-
ml_value_t MLSome[]¶
A non-
nil
value. Has no other use.
-
int ml_is(const ml_value_t *Value, const ml_type_t *Type)¶
Returns 1 if
Value
is an instance ofType
or a subtype, returns 0 otherwise.
-
long ml_hash_chain(ml_value_t *Value, ml_hash_chain_t *Chain)¶
Returns a hash value for
Value
. UsesChain
to break cycles while hashing.Chain
can beNULL
for the top-level call toml_hash_chain()
, hash functions for structures which may introduce cycles should create a newml_hash_chain_t
and pass that to their calls toml_hash_chain()
.
-
long ml_hash(ml_value_t *Value)¶
Equivalent to
ml_hash_chain()
.
-
type ml_hash_chain_t¶
If
ml_hash_chain()
is called with a value already in the chain, the previous index is returned, preventing cycles.-
ml_hash_chain_t *Previous¶
Previous link in the hash chain.
-
ml_value_t *Value¶
The value that was encountered.
-
long Index¶
The previous index when the value was encountered.
-
ml_hash_chain_t *Previous¶
-
void ml_iterate(ml_state_t *Caller, ml_value_t *Value)¶
Start iterating over
Value
. ResumesCaller
with an iterator (ornil
ifValue
is empty, or anerror
ifValue
is not sequence or another error occurs).
-
void ml_iter_value(ml_state_t *Caller, ml_value_t *Iter)¶
-
void ml_iter_key(ml_state_t *Caller, ml_value_t *Iter)¶
-
void ml_iter_next(ml_state_t *Caller, ml_value_t *Iter)¶