Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!siemens!princeton!news.princeton.edu!blume
From: blume@dynamic.cs.princeton.edu (Matthias Blume)
Subject: Re: Explanation about call-with-values
In-Reply-To: Alan@lcs.mit.EDU's message of 25 Jan 1995 03:43:55 -0500
Message-ID: <BLUME.95Jan25121652@dynamic.cs.princeton.edu>
Originator: news@hedgehog.Princeton.EDU
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: dynamic.cs.princeton.edu
Organization: Princeton University
References: <BLUME.95Jan24114128@dynamic.cs.princeton.edu>
	<25Jan1995.015625.Alan@LCS.MIT.EDU>
Date: Wed, 25 Jan 1995 17:16:52 GMT
Lines: 63

In article <25Jan1995.015625.Alan@LCS.MIT.EDU> Alan@lcs.mit.EDU (Alan Bawden) writes:

   I'm not disagreing with Matthias by what I'm about to write here.  (In
   truth I suspect I do disagree with his position -- but I haven't been
   following the argument with enough attention to want to get involved.)  I'm
   simply reacting to a single phrase in the quoted text above:

     "the continuation of the call to `f' only takes one argument"

   [ ... goes on by showing different interpreters with different behaviors,
     in some of which my statement is true, in some of which it would be
     false ... ]

   So before we even start arguing about multiple values, we'd better decide
   which kind of interpreter we all believe in.  I hasn't mattered until now,
   indeed there wasn't any way to tell the difference, but we're contemplating
   new language features where it -may- make a difference, so we need to be
   clear about it.  Sloppy language like:

     "the continuation of the call ... only takes one argument"

   can get us in trouble because it -assumes- a particular kind of interpreter
   before we even get started.

I always thought that stuff like this is a matter of the language
*definition*.  (While giving a `reference' interpreter might be one way
to do this, there are some things to watch out for when using
metacircular evaluators.)

Anyway, this is not the point.  We do have (sort of) a definition of
what is supposed to happen.  It was written down in the famous `the
june 1992 meeting' paper.  R5RS (as far as I know) doesn't exist, and
IEEE Scheme doesn't mention `values' either.  So let's look at what
the `june' paper says...  My copy has it on page 3 (at the very top):

``... Except for continuations created by the call-with-values
procedure, all continuations TAKE EXACTLY ONE value, as now; the
effect of passing no value or more than one value to continuations
that were not created by call-with-values is unspecified (as indeed
it is unspecified now). ...'' (emphasis mine)

This sounds fairly clear to me, so all this discussion of different
interpreters is moot.   If I want to write portable Scheme code (under
the new rules, against which I tried to argue), I have to use

        (define (g x)
          (call-with-values
            (lambda () (f x))
            (lambda r
              <do something else>
              (apply values r))))

instead of the straightforward

        (define (g x)
          (let ((r (f x)))
            <do something else>
            r))

unless I know exactly how many values `f' is going to return.

--
-Matthias
