Nyquist / XLISP 2.0 -
Contents |
Tutorials |
Examples |
Reference
cl:values
The cl:values function evaluates all given Lisp
expressions and returns the results as multiple values:
- (cl:values [expr1 ...])
- exprN - an arbitrary Lisp expression
returns - the results of evaluating the expressions, as multiple values
(defun cl:values (&rest exprs)
(setq *rslt* exprs
cl:*multiple-values* t)
(first exprs))
The primary return value [the result from evaluating the
first expression] is returned by the cl:values function
and a list with the results of evaluating all expressions is assigned to the
Nyquist *rslt* variable.
If no expressions are given,
NIL is returned and the
*rslt* variable is set
to NIL.
The
cl:*multiple-values*
variable is set
to T
to indicate that multiple values are returned.
Examples:
(cl:values 1 2 3) => 1 ; primary value
*rslt* => (1 2 3) ; all values
(cl:values 'a 'b) => A ; primary value
*rslt* => (A B) ; all values
> (cl:multiple-value-bind (a b c)
(cl:values 1 2 3)
(list a b c))
(1 2 3)
See
cl:multiple-value-bind,
list,
*rslt*.
Known Limitations
1. In Nyquist/XLISP, cl:values cannot be
used as argument to setf. But
this is not a real problem, because the values are stored as a
simple list in the *rslt*
variable, where they can be manipulated with any arbitrary Lisp
functions, not only with
setf.
2. In Common Lisp there exists the option to return
'no value' by calling the 'values' function with no arguments.
In Nyquist/XLISP there is no built-in way to
return 'no value' from a function. The symbol
*unbound* cannot be used for
this because in Common Lisp, if 'no value' is
assigned to a symbol as variable value, the new value will be
NIL and not
*unbound*.
In Nyquist/XLISP, the cl:values function, if called with no
arguments, always returns NIL, and the
*rslt* variable will be
set to NIL, too:
(cl:values) => NIL ; primary value
*rslt* => NIL ; all values
(cl:values nil) => NIL ; primary value
*rslt* => (NIL) ; all values
Maybe this observation helps to write a 'no values' test if
anybody really needs it.
Back to top
Nyquist / XLISP 2.0 -
Contents |
Tutorials |
Examples |
Reference