;;AUTOLOAD: verbose?
;;AUTODOC: verbose? "print-format in verbose mode"
;;(verbose? [:n] format-string args)
;;
;;If the verbose global variable is set, will do a print-format with
;;args on stderr and flush, and add a terminating newline.
;;If verbose is (), do not even evaluates its arguments
;;If you dont want a newline added, add :n as first parameter
;;e.g.:
;;    (defun add1 (x)
;;       (verbose? "add1: x = %0" x)
;;       x)

(defunq verbose? (&rest verbose?args)
  (if verbose (with (nonewline () eval-args (list))
      (dolist (arg verbose?args) (lappend eval-args (eval arg)))
      (if (= :n (getn eval-args 0)) (progn
	  (setq nonewline t)
	  (setq eval-args (subseq eval-args 1))
      ))
      (apply print-format (+ (list *standard-error*) eval-args))
      (if (not nonewline) (print-format *standard-error* "\n"))
      (flush *standard-error*)
)))
