Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

cl:debug:mv


The cl:debug:mv function can be used to debug multiple value expressions:

(cl:debug:mv expr
expr - a Lisp expression, returning an arbitrary number of values
returns - the normal Lisp return value from evaluating expr

(defun cl:debug:mv (expr)
  (setq cl:*multiple-values* nil)
  (let ((result (eval expr)))
    (format t ";; cl:*multiple-values* => ~a~%" cl:*multiple-values*)
    (format t ";; *rslt* => ~a~a~%" *rslt*
              (if cl:*multiple-values* "" " [invalid]"))
    result))

The cl:debug:mv function first sets the cl:*multiple-values* variable to NIL, then it evaluates the expression. After evaluation it prints the values of the cl:*multiple-values* and *rslt* variables and returns the normal Lisp return value from the evaluation.

Example:

> (cl:debug:mv '(cl:values 1 2 3))
;; cl:*multiple-values* => T
;; *rslt* => (1 2 3)
1

> (cl:debug:mv 1)
;; cl:*multiple-values* => NIL
;; *rslt* => (1 2 3) [invalid]
1

  Back to top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference