Path: utzoo!utgpu!water!watmath!clyde!ima!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.misc Subject: Re: The need for D-scussion (was Re: D Wishlist) Message-ID: <18643@think.UUCP> Date: 30 Mar 88 02:57:33 GMT References: <12176@brl-adm.ARPA> <1988Mar11.215238.976@utzoo.uucp> <719@l.cc.purdue.edu> <10763@mimsy.UUCP> <3177@haddock.ISC.COM> <18580@think.UUCP> Sender: usenet@think.UUCP Reply-To: barmar@fafnir.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 33 In article gaynor@porthos.rutgers.edu (Silver) writes: >barmar@think.COM (Barry Margolin) writes: >> (setq z (multiple-value-bind (quotient remainder) >> (floor x y) >> (+ (* quotient quotient) (* remainder remainder)))) > How would Scheme's >continuations fit into the area of multiple return values? Continuations would have to be extended to be able to take multiple arguments. In order to precisely duplicate Common Lisp multiple-value semantics, the above MULTIPLE-VALUE-BIND would call FLOOR with a continuation of (lambda (continuation &optional quotient remainder &rest ignore) (continuation (+ (* quotient quotient) (* remainder remainder)))) (I'm using CL lambda-list syntax because I'm not very familiar with Scheme syntax). This duplicates the feature of allowing the function to return a different number of values than those explicitly requested, where extra values are ignored and values not provided are defaulted to NIL. (values ...) is then equivalent to (continuation ...) and (values-list list) is (apply continuation list). Converting the rest of the multiple-value forms is similarly straightforward. Barry Margolin Thinking Machines Corp. barmar@think.com uunet!think!barmar