From: Dick King
Subject: Multiple Return values in Common Lisp.
Date: 
Message-ID: <15257@kestrel.ARPA>
   From: ······@sunybcs.UUCP (James Geller)
   Newsgroups: comp.lang.lisp
   Date: 2 Dec 86 16:52:34 GMT
   Sender: ······@sunybcs.UUCP
   Reply-To: ······@sunybcs.UUCP (James Geller)

   I don't consider myself a great expert on Common Lisp, but
   it seems to me that the idea of "multiple return values" of 
   Common Lisp is ill conceived.  This is not to say that one 
   does not need multiple return values, but that they should be
   used in a conceptually different way.

I disagreee that it's as bad as you think.


   Example:

	     (defun extent (rectangle-name)

   ;;            This returns the x-length of the rectangle "rectangle-name"
   ;;            It also returns the y-length as a multiple
   ;;            return value.

		  .......)


	     (defun perimeter (rectangle-name)

   ;;              This uses both, the "normal" and the "multiple"
   ;;              return value.  It computes the perimeter of the
   ;;              rectangle "rectangle-name".

		    (+ (* (extent/1 rectangle-name) 2)
		       (* (extent/2 #*) 2)))

This would be better rendered

  (multiple-value-bind (length width) (extent rectangle-name)
      (+ (* length 2) (* width 2)))


   Example:

	    (defun square-of-hard-to-get-number (argument)

		(* (long-computation argument)
		   (long-computation #*)))

   People who don't hesitate to use a "setq" will not understand
   why I don't write:

	    (defun square-of-hard-to-get-number (argument)

		(* (setq dummy (long-computation argument))
		   dummy))

   But I have been raised in the tradition of functional programming.

   So I end up writing 

	     (defun helper (argument)
		 (square-variant (long-computation argument))) 

	     (defun square-variant (hard-to-get-number)
		 (* hard-to-get-number hard-to-get-number))

It's better to write

(defun square-of-grody-comp (n)
   (let ((val (long-computation n)))
      (* val val)))


   Or a lambda expression with the same effect.  This is really
   an unnecessary inconvinience.

			   Jim

   P.S.  Should this subject have been brought up already, my apology.
	 I missed some news over diverse breaks.

-dick
From: Stanley Shebs
Subject: Re: Multiple Return values in Common Lisp.
Date: 
Message-ID: <4076@utah-cs.UUCP>
For those who need academic approval for features of Common Lisp, I offer
Peter Henderson's book "Functional Programming: Application and
Implementation", page 269:

"For practical purposes, however, ... our purely functional language [is]
in fact very rudimentary, and some very simple extensions would greatly
enhance its ability to express clearly certain classes of computation.
... That purely syntactic extensions can have great power, in terms of
improved clarity of expression, is illustrated by the extension which we
now undertake."

"We extend our purely functional language to allow functions to return
multiple results. ..."

He then goes on to describe some constructs which are essentially VALUES
and MULTIPLE-VALUE-BIND in CL.  CL's multiple values are somewhat more
complicated, partly because it needs to work with the rest of the language,
and partly because Henderson's version has some undesirable limitations
(must always have exact match of multiplicities, for instance).

							stan