io.randomseed.utils.var

added in 1.0.0

Random utils, global variables handling.

alter

macro

(alter v f & args)

deref

(deref v)

Takes a symbol and resolves it using resolve and then dereferences it.

deref-symbol

(deref-symbol v)

Takes a symbol and resolves it using resolve and then dereferences it. If the given value is not a symbol it is returned.

deref-with-call

(deref-with-call v)

Tries to resolve a symbol and then dereference a Var if the symbol points to a it or if it was already a Var. If the Var points to a functions or it is a function object already then it will . For a vector it makes a new vector by applying this operation to all of its elements.

make

(make n value)

Creates a Var identified in a namespace with a fully qualified identifier n and sets its value to value. If the Var does not exist, it will be created. Returns the given value used to change the root binding of a Var.

reset

macro

(reset v val)

resolve

(resolve v)

Takes a symbol and resolves it, trying to load a namespace if a namespace-qualified symbol is provided. For vectors it applies this operation to all values and produces a new vector.

update

(update n f & args)

Updates a Var identified in a namespace with a fully qualified identifier n, using a function f. The function will receive current value of the Var and any optional arguments passed, and its returned value will be used to alter the root binding. If the Var does not exist, it will be created and the function f will receive nil as its first argument. Returns a value returned by calling f.