This is the mail archive of the mailing list for the Guile project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: values (Re: R5RS)

>>>>> "C" == C Ray C <crayc@> writes:

C> On Mon, Feb 28, 2000 at 03:52:26PM -0500, Jim Blandy wrote:

>> [...deleted]
>> Then I can say:
>> let val (quotient, remainder) = divide (a, b)
>> in ...
>> You get multiple return values in a completely natural, consistent,
>> and convenient form.

C> That sort of thing would be useful, but a new data type isn't
C> necessary. 

Precisely, it is not the tuple type at work in ML, it is the multiple
values `let'.

C> Perhaps you could add something like a list binding macro, where
C> you bind elements in a list to variables. Like, if we called it
C> "list-let"...

CommonLisp calls it (in the words of the hyperspec):



multiple-value-bind (var*) values-form declaration* form*

=> result*

Arguments and Values:

var---a symbol naming a variable; not evaluated.
values-form---a form; evaluated.
declaration---a declare expression; not evaluated.
forms---an implicit progn.
results---the values returned by the forms.


Creates new variable bindings for the vars and executes a series of forms that
use these bindings.

The variable bindings created are lexical unless special declarations are

Values-form is evaluated, and each of the vars is bound to the respective
value returned by that form. If there are more vars than values returned,
extra values of nil are given to the remaining vars. If there are more values
than vars, the excess values are discarded. The vars are bound to the values
over the execution of the forms, which make up an implicit progn. The
consequences are unspecified if a type declaration is specified for a var, but
the value to which that var is bound is not consistent with the type

The scopes of the name binding and declarations do not include the


 (multiple-value-bind (f r) 
     (floor 130 11)
   (list f r)) =>  (11 9)

Christian Lynbech          | Ericsson Telebit A/S                       
Fax:   +45 8628 8186       | Fabrikvej 11, DK-8260 Viby J
Phone: +45 8738 2228       | email: --- URL:
Hit the philistines three times over the head with the Elisp reference manual.
                                        - (Michael A. Petonic)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]