Article View: comp.lang.misc
Article #5424Re: Multiple values
From: Jeff Dalton
Date: Thu, 31 Mar 1988 22:47
Date: Thu, 31 Mar 1988 22:47
40 lines
1964 bytes
1964 bytes
Gaynor@porthos asks
:How would Scheme's continuations fit into the area of multiple
:return values?
In article <8121@sol.ARPA> quiroz@cs.rochester.edu (Cesar Quiroz) writes:
>In a capsule:
>1- Returning == Calling a continuation
>so
>2- Returning multiple values == Calling a continuation with multiple
>arguments.
>I believe Scheme doesn't have this class of continuations. (Scheme's
>continuations take only one argument). However, that this modification
>is possible has been known for a long time [...], so I wouldn't be
>surprised if at least one implementation has supported multiple values.
T does more or less what you suggest. You can write
(receive-values receiver sender)
to call receiver with the values returned by sender. Sender should
be a "thunk" that returns the right number of values when called.
Return is used to return multiple values. So
(receive-values
(lambda (a b c) (list a b c))
(lambda () (return 1 2 3))) => (1 2 3)
Then,
(reveive (<variable>*) <values-expr> <expr>*)
==
(receive-values
(lambda (<variable>*) <expr>*)
(lambda () <values-expr>))
Jeff Dalton, JANET: J.Dalton@uk.ac.ed
AI Applications Institute, ARPA: J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk
Edinburgh University. UUCP: ...!ukc!ed.ac.uk!J.Dalton
Technical Details
Message-ID:
<313@aiva.ed.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!its63b!aiva!jeffReferences:
<12176@brl-adm.ARPA> <1988Mar11.215238.976@utzoo.uucp> <719@l.cc.purdue.edu> <10763@mimsy.UUCP> <3177@haddock.ISC.COM> <18580@think.UUCP> <Mar.28.12.43.35.1988.1511@porthos.rutgers.edu> <8121@sol.ARPA>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!its63b!aiva!jeff From: jeff@aiva.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.misc Subject: Re: Multiple values Message-ID: <313@aiva.ed.ac.uk> Date: 31 Mar 88 22:47:38 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> <Mar.28.12.43.35.1988.1511@porthos.rutgers.edu> <8121@sol.ARPA> Reply-To: jeff@uk.ac.ed.aiva (Jeff Dalton) Organization: Dept. of AI, Univ. of Edinburgh, UK Lines: 40