Parameters are named values that are defined and used in computations or in presentation; the concept is distinct from Common Lisp's defparameter macro. They are organized into named categories; Antik itself defines one category, NF, which is used for numerical formatting. Each parameter is defined with a default value and description. The value can be changed with (setf parameter-value) and used with parameter-value, or changed locally (analogous to let for CL variables) with with-parameters.
;;; First create the category
(define-parameter-category kepler)
;;; Then define some parameters
(define-parameter kepler foo 122 fixnum "A fixnum parameter of kepler.")
(define-parameter kepler bar "hi" string "A string parameter of kepler.")
;;; Get their values
(parameter-value kepler bar)
"hi"
(parameter-value kepler foo)
122
;;; Dynamic binding
(defun show-foo-bar ()
(format t "~&foo: ~a, bar: ~s"
(parameter-value kepler foo)
(parameter-value kepler bar)))
(show-foo-bar)
foo: 122, bar: "hi"
NIL
;;; Locally change values
(with-parameters (kepler foo 143 bar "bye")
(show-foo-bar))
foo: 143, bar: "bye"
NIL
(show-foo-bar)
foo: 122, bar: "hi"
NIL
;;; Make a mistake
(with-parameters (kepler foo 143 bar -44)
(show-foo-bar))
Error: Value -44 is of type FIXNUM, not of the required type STRING.
;;; Globally change values
(set-parameter-value kepler bar "a new value")
foo: 122, bar: "a new value"
;;; Set multple values
(set-parameters kepler bar "xyz" foo 1)
;;; Get information about the categories and parameters
(parameter-help)
Parameter categories: KEPLER.
(parameter-help :kepler)
Parameters in KEPLER: BAR and FOO.
(parameter-help :kepler :bar)
BAR: A string parameter of kepler.
Type is: STRING, default value is "hi".
(parameter-value* kepler (mkstr "FO" "O"))
122
Print all information known about the parameter. If category is nil (default), names of all categories are printed. If name is nil, all defined parameters in that category are printed.
Reset the parameter(s) to the default value; if none are specified, all in the category are reset.