After the recent change to support for user defined arithmetic functions, I’ve been experimenting with library(settings); the doc suggests that env (arity 1 and 2) should evaluate to numeric values in arithmetic expressions, but I can’t make it work. A simple test module:
:- module(test_settings,[fsetting/2]).
:- use_module(library(settings)).
:- setting(version, atom, '1.0', 'Current version').
:- setting(timeout, number, 20, 'Timeout in seconds').
After loading:
?- list_settings.
========================================================================
Name Value (*=modified) Comment
========================================================================
test_settings:version '1.0' Current version
test_settings:timeout 20 Timeout in seconds
true.
As I understand it env(timeout) or possibly env(test_settings:timeout) in an arithmetic expression should evaluate to 20, but I get nothing but errors. Looking at the code in library(settings) and library(arithmetic) probable causes are:
envis not exported fromlibrary(settings). As I understand the recent change (9.1.22) tolibrary(arithmetic)this is necessary to useenvas a function outside the defining module.timeoutandtest_settings:timeoutare not valid arguments to an arithmetic function as defined byarithmetic:math_goal_expansion.- The implementation of
settings:envjust callsgetenvwhich expects ‘text’ as a name. (My rudimentary understanding ofsettingssuggests some form of module qualification is necessary.)
I don’t consider this a big issue - I can find no examples of usage in the SWIP release, but I’d like to understand how one uses the current arithmetic library for defining new arithmetic functions.