Statifier.Evaluator.Functions (Statifier v2.0.0)

Copy Markdown View Source

The Predicator.FunctionProvider carrying In/1 (spec 5.9.1), replacing Statifier.Evaluator's former private closure-building helper.

A provider entry is named by {module, atom} rather than by a captured function() value (deps/predicator/lib/predicator/functions/provider.ex), so in_state/2 reads the current configuration from its %Predicator.Context{} argument's host slot instead of closing over it. Statifier.Evaluator.context/1 sets host to {machine, configuration} and refreshes it per site with Predicator.Context.put_host/2 - see that module's moduledoc for why this dissolves the "not a resumable position" ground the closure used to force.

Summary

Functions

The fixed half of every context this library builds: an empty data, a nil host, on_unbound: :error, and functions resolved once at compile time to %{"In" => {1, {Statifier.Evaluator.Functions, :in_state}}} plus the four builtin providers. Statifier.Evaluator.context/1 starts from this constant on every call, then layers in host via Predicator.Context.put_host/2 and the datamodel via Statifier.Evaluator.bind/3 - so Predicator.Context.new/2 and Predicator.Context.resolve_functions/1 never run on that hot path.

This provider's one entry: In/1, dispatched to in_state/2.

In(stateId): true when stateId names a state in context.host's configuration, false for an inactive or undeclared state id.

Functions

base_context()

@spec base_context() :: Predicator.Context.t()

The fixed half of every context this library builds: an empty data, a nil host, on_unbound: :error, and functions resolved once at compile time to %{"In" => {1, {Statifier.Evaluator.Functions, :in_state}}} plus the four builtin providers. Statifier.Evaluator.context/1 starts from this constant on every call, then layers in host via Predicator.Context.put_host/2 and the datamodel via Statifier.Evaluator.bind/3 - so Predicator.Context.new/2 and Predicator.Context.resolve_functions/1 never run on that hot path.

Two calls return the same term; nothing about this value varies at runtime.

functions()

@spec functions() :: %{required(String.t()) => {non_neg_integer(), atom()}}

This provider's one entry: In/1, dispatched to in_state/2.

in_state(list, context)

@spec in_state(args :: [Predicator.Types.value()], context :: Predicator.Context.t()) ::
  {:ok, boolean()}

In(stateId): true when stateId names a state in context.host's configuration, false for an inactive or undeclared state id.

context.host must be {machine, configuration}, the shape Statifier.Evaluator.context/1 sets via Predicator.Context.put_host/2.