scsh-users
[Top] [All Lists]

Re: ??? call-with-values ???

To: kaelin@bridge.com
Subject: Re: ??? call-with-values ???
From: Olin Shivers <shivers@clark.lcs.mit.edu>
Date: Tue, 15 Nov 94 18:29:57 -0500
Cc: scsh@martigny.ai.mit.edu
Reply-to: shivers@mintaka.lcs.mit.edu
   From: Kaelin Colclasure <kaelin@bridge.com>

   I am having difficulty with the new call-with-values procedure in
   Scheme48.  I am familiar with Common Lisp, so I had no trouble at all
   with the (values ...) form or with the concept of multiple return
   values in general.  I simply cannot deduce how a procedure which
   returns multiple values is to be applied using call-with-values.

Here's a typical use:
    > (call-with-values (lambda () (values 3 4)) cons)
    '(3 . 4)

    > (receive (a b) (values 3 4)
        (cons a b))
    '(3 . 4)
    > 

It's (call-with-values THUNK CONSUMER). 
RECEIVE is a macro that expands as follows:
    (receive (VAR1 ...) EXP 
      BODY ...)
    =>
    (call-with-values (lambda () EXP) (lambda (VAR1 ...) BODY ...))

You get the RECEIVE macro from the RECEIVING package in S48.
    -Olin

<Prev in Thread] Current Thread [Next in Thread>