From: Chris Marusich <cmmarusich@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-user@gnu.org
Subject: Re: Multiple values passed as single argument to procedure
Date: Sun, 11 Jun 2017 17:19:47 -0700 [thread overview]
Message-ID: <87zidexdjw.fsf@gmail.com> (raw)
In-Reply-To: <87k24i2rev.fsf@netris.org> (Mark H. Weaver's message of "Sun, 11 Jun 2017 16:36:08 -0400")
[-- Attachment #1: Type: text/plain, Size: 2796 bytes --]
Hi Mark,
Thank you for the detailed response! I learn something new every day.
Mark H Weaver <mhw@netris.org> writes:
> 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.
I see. So, this behavior is implementation-specific for Guile scheme.
Is this behavior documented in the Guile reference manual? I looked,
but I couldn't find information about it. So, it is not clear to me if
one should rely on this behavior, or if it is likely to change in the
future. I was hoping to find this behavior documented in either
"(guile) Multiple Values" or somewhere in "(guile) About Procedures".
Perhaps there's a better location. In any case, I think it would be
helpful if this were documented in the manual.
Here's another question. I've also noticed that when the 'list'
procedure is composed with a procedure f that returns multiple values,
the list that gets returned when calling the composition differs from
the list that results when "manually" invoking the same composition. An
example will clarify what I mean:
--8<---------------cut here---------------start------------->8---
$ guile
GNU Guile 2.2.2
Copyright (C) 1995-2017 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> (define (f . _) (values 1 2))
scheme@(guile-user)> (f)
$1 = 1
$2 = 2
scheme@(guile-user)> (define g (compose list f))
scheme@(guile-user)> (g)
$3 = (1 2)
scheme@(guile-user)> (list (f))
$4 = (1)
scheme@(guile-user)>
--8<---------------cut here---------------end--------------->8---
In the above, I was surprised to find that $3 was not the same as $4.
To put this another way, I was surprised to find that the composition
via 'compose' (which returned $3) did not behave the same as the
'manual' composition (which returned $4). What's going on here? I
couldn't find the answer by looking at the documentation for the compose
((guile) Higher-Order Functions) or list ((guile) List Constructors)
procedures in the Guile manual.
Thank you for taking the time to help me understand this better.
--
Chris
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2017-06-12 0:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-11 7:56 Multiple values passed as single argument to procedure Chris Marusich
2017-06-11 8:28 ` David Kastrup
2017-06-11 20:36 ` Mark H Weaver
2017-06-11 21:31 ` Mark H Weaver
2017-06-12 0:19 ` Chris Marusich [this message]
2017-06-12 4:25 ` Mark H Weaver
2017-06-12 8:19 ` Chris Marusich
2017-06-12 8:55 ` Neil Jerram
2017-06-12 9:48 ` Neil Jerram
2017-06-12 9:39 ` David Kastrup
2017-06-12 11:31 ` Mark H Weaver
2017-06-12 14:24 ` David Kastrup
2017-06-13 2:26 ` Mark H Weaver
2017-06-13 3:09 ` Mark H Weaver
2017-06-13 3:45 ` Mark H Weaver
2017-06-13 11:17 ` dsmich
2017-06-26 11:25 ` Alex Vong
-- strict thread matches above, loose matches on Subject: below --
2017-09-01 19:39 Chris Marusich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zidexdjw.fsf@gmail.com \
--to=cmmarusich@gmail.com \
--cc=guile-user@gnu.org \
--cc=mhw@netris.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).