environment A global environment/context management system for Scryer Prolog providing key-value metadata storage one level of abstraction above the blackboard. Purpose This library provides a clean interface for managing global state in Prolog programs using association trees (AVL trees) backed by the blackboard. It offers: Global persistent storage - Changes persist across backtracking - Changes persist across backtracking Backtrackable local storage - Changes roll back on backtracking - Changes roll back on backtracking Type-safe reified predicates - Use if_/3 for conditional logic without cuts - Use for conditional logic without cuts Once-only initialization - Prevent accidental double initialization - Prevent accidental double initialization Key existence checking - Efficiently check for key presence Installation Using Bakage bakage.pl install environment Manual Installation Copy environment.pl to your project's library directory or ensure it's in your Scryer Prolog load path. Dependencies library(reif) - Reified predicates for conditional logic - Reified predicates for conditional logic library(assoc) - Association trees (AVL trees) - Association trees (AVL trees) library(iso_ext) - ISO extensions including blackboard predicates Quick Start ?- use_module(library(environment)). % Set global values (persistent across backtracking) ?- env_set_global(username, 'Alice'). true . ?- env_set_global(counter, 42). true . % Retrieve values ?- env_key_val(username, User). User = 'Alice' . % Check if key exists (reified) ?- env_check_flag_t(username, T). T = true . % Set local value (backtrackable) ?- env_set_local(temp, 'temporary'), env_key_val(temp, V). V = 'temporary' . % Initialize once (prevents double initialization) ?- env_set_global_once(config_loaded, true). true . ?- env_set_global_once(config_loaded, false). ERROR : runtime_error( env_set_global_once ) API Reference Core Operations Retrieve the current global environment as an association tree. Replace the enti...
First seen: 2025-10-25 22:39
Last seen: 2025-10-25 22:39