[Openmcl-devel] help with return values

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Tue Jan 21 10:40:50 PST 2014


I am currently writing a program (a CL compiler) and I found a difficulty to
handle return values efficiently; an example will show what I mean

(comp form) -> returns (values compiled-code return-values)

for example when compiling a progn the return-values is the return of the
last form in the progn; since I do not know how many values the last form
returns I am forced to do as follow:

;;; the real code is not like this it is just a pseudo code to explain the
(multiple-value-bind (c v) (comp form)
  (let ((x (new-var)))
       `(, at c (setq ,x (multiple-value-list ,(car v)))) ;;; return compiled
       '((values-list ,x))))   ;;; this will be used by the user of the form

for example if code is (+ 1 (progn 2 3))
the compiled code will be :
   2; (setq x (multiple-value-list 3)); (+ 1 (values-list x))

This works in all cases but it is inefficient because sometimes
and values-list are not necessary when the last form of progn returns
exactly one

Any idea how to handle this more efficiently?

Kind regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20140121/47bfeae2/attachment.htm>

More information about the Openmcl-devel mailing list