Commit 9fcf39af authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Check that a named parameter exists

Check that a named parameter exists and signal an error if it does not.
parent 8d4bd257
;; Global/local parameters to pass to functions
;; Liam Healy 2013-02-16 20:51:14HST variable-metadata.lisp
;; Time-stamp: <2013-05-29 12:21:19EDT parameters.lisp>
;; Time-stamp: <2013-05-31 18:12:51EDT parameters.lisp>
;; Copyright 2011, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -92,7 +92,12 @@
(remove-if-not (lambda (p) (eq (symbol-package p) pkg)) *parameters*))))
(defun find-parameter (category name)
(canonical-parameter-name (find-parameter-symbol category name)))
"Find the registered parameter."
(let ((symbol (find-parameter-symbol category name)))
(multiple-value-bind (can found)
(canonical-parameter-name symbol)
(if found can
(error "Parameter ~a:~a not defined." category name)))))
;;;; Definition and use
......@@ -205,13 +210,15 @@
append (list `(parameter-value ,category ,(first nv)) (second nv)))))
(with-parameters (nf (no-units t))
(with-parameters (:nf (:style 44))
(foobar (parameter-value :nf :style)))
(with-parameters (:nf (:zibble 44))
(foobar (parameter-value :nf :zibble)))
;;;; Help
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment