Multiple value return propogation
Multiple value return propogation
I want to do something like this.
(defun func ()
(multiple-value-bind (arg ...an unknown amount of returns) (func2)
(if (...a test using arg value...) (progn ;;do something) (values arg ..somehow return all values returns by func2))))
In other words i want to 'propogate the multiple return value returned by func2. Is there any way to do this?
Thx
Re: Multiple value return propogation
Short answer: Yes, look at MULTIPLE-VALUE-LIST.
I assume that you already know that a function like,
will propagate the multiple values from FLOOR. Not the most flexible method, since it won't work if you want to store the return from FLOOR first. The general way is to use MULTIPLE-VALUE-LIST like so,
All sorts of things you can do along these lines. Check out MULTIPLE-VALUE-COMPOSE in the Alexandria utility library for some real world working of this.
Best,
Zach S
I assume that you already know that a function like,
Code: Select all
(defun my-floor (x y)
(floor x y) )
Code: Select all
(defun func ()
(let ((vals (multiple-value-list (func2))))
(cond ((test (car vals))
...do something... )
(t (values-list vals)) )))
Best,
Zach S
Re: Multiple value return propogation
That['s exactly what i wanted to do. Thx, especially for that reference to multiple-value-compose