Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!panda!genrad!decvax!decwrl!labrea!kestrel!king From: king@kestrel.ARPA (Dick King) Newsgroups: comp.lang.lisp Subject: Multiple Return values in Common Lisp. Message-ID: <15257@kestrel.ARPA> Date: Thu, 4-Dec-86 14:44:58 EST Article-I.D.: kestrel.15257 Posted: Thu Dec 4 14:44:58 1986 Date-Received: Fri, 5-Dec-86 04:46:21 EST Organization: Kestrel Institute, Palo Alto, CA Lines: 82 From: geller@sunybcs.UUCP (James Geller) Newsgroups: comp.lang.lisp Date: 2 Dec 86 16:52:34 GMT Sender: nobody@sunybcs.UUCP Reply-To: geller@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