guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple values passed as single argument to procedure


From: Mark H Weaver
Subject: Re: Multiple values passed as single argument to procedure
Date: Sun, 11 Jun 2017 16:36:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Chris Marusich <address@hidden> writes:
> I've noticed that when one passes multiple values as a single argument
> to a procedure, only the first value gets used.  Is this expected?

Yes.  Scheme has no concept of a "multiple values" object that can be
given a single name, or passed as a single argument to a procedure.
Returning multiple values from a procedure is analogous to passing
multiple arguments to a procedure.

Use 'call-with-values', 'let-values', or 'receive' to call a procedure
that returns multiple values (or no values).

If you do not use one of the above forms (or a macro that expands to one
of them) to call a procedure that returns multiple values, then Guile
will discard all but the first result.  Note that this is a
Guile-specific extension.  Other Scheme implementations may behave
differently (e.g. report an error) if multiple values (or no values) are
returned to a procedure call that was not done using one of the forms
listed above.

      Mark


PS: I should mention that Guile does indeed have a "multiple values"
    object at the C level only, to allow C code to return or accept
    multiple values without uglifying the C calling convention for
    Scheme procedures.  This is to work around the fact that C does not
    support returning multiple values from a function.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]