From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Chris Marusich Newsgroups: gmane.lisp.guile.user Subject: Re: Multiple values passed as single argument to procedure Date: Sun, 11 Jun 2017 17:19:47 -0700 Message-ID: <87zidexdjw.fsf@gmail.com> References: <87mv9fnejc.fsf@gmail.com> <87k24i2rev.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1497226823 17236 195.159.176.226 (12 Jun 2017 00:20:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Jun 2017 00:20:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 12 02:20:17 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKD5c-0003rr-Jz for guile-user@m.gmane.org; Mon, 12 Jun 2017 02:20:16 +0200 Original-Received: from localhost ([::1]:35566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKD5d-0000HM-91 for guile-user@m.gmane.org; Sun, 11 Jun 2017 20:20:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKD5J-0000HH-4m for guile-user@gnu.org; Sun, 11 Jun 2017 20:19:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKD5I-0003Ek-2I for guile-user@gnu.org; Sun, 11 Jun 2017 20:19:57 -0400 Original-Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:34624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKD5H-0003Ec-Sg for guile-user@gnu.org; Sun, 11 Jun 2017 20:19:55 -0400 Original-Received: by mail-pf0-x236.google.com with SMTP id 15so17951811pfc.1 for ; Sun, 11 Jun 2017 17:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=kRMlkrDxiaUpREShYT3uMpqKrCGCd+Y1GFXZCIOd+XA=; b=JxN8LzmzJwqOTjXOfQJHXYtJTgdnfpwjUwl1rHxTgQIOim6eCT8UW9yldkFqqP60dA mu7VVNORvQ/NTga+yIztEk/BzRiOajxNrHc7925qu3RPAnlwya4T5fo+7waV1Lczfs/B C+ol8W8uA/m0ya3XOTf1l52VHDBKBqSlqbA503AllGjubfuel6uCqylINljlrAjgTr0J 51wBeVsOAK24rcg+QGToM2xsY3jhRPoJSHJX4aFawBCl1W0TsfPB2M9LDcds4PY88lGJ iibQb10c9wfyJsxHwKJZFHmk8M1AJMjVYMuI0oVDCPMl82BZVQeBm02Pf3Y/y/74hyBK UP6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=kRMlkrDxiaUpREShYT3uMpqKrCGCd+Y1GFXZCIOd+XA=; b=baVrVjsCi0zIhZN6/qlTl85Hpryj6/XF+ei6VcjgxTC6lw+bEzE2JGf9gqO2SXRRji l8vuIJrGHZwfectskqw7IgpclhFEkHSJnEqlu/sv7rsHLevF0419RqsqzClMDTnqEdl4 EaHGLQMM1qHrnTi0xOvUrfKeon+vxDIFBNh8gw31jy4P7IVajof6oH8fmgWD4ndGAQK/ HaKFAXitXdjkRmooKKBsbcGIEQDgJtvxRYcGMal5VnmTMoCCfR2qsmIJKf4UyKXWfey/ TfmYhiX/ErAEcyinyi3E0/e/RX01OzQUKYA7zuCalf/fzBIm+8xN7p8GPmhVt0ZY36Vw wiUg== X-Gm-Message-State: AODbwcAuIfOgap2iWarm8LqoeVkYJGSBDmCMR5H1OPY4oX1jMAqJGLy5 h/YYW2PQm1DTVJSF X-Received: by 10.98.33.205 with SMTP id o74mr36077623pfj.11.1497226794431; Sun, 11 Jun 2017 17:19:54 -0700 (PDT) Original-Received: from garuda ([2601:602:9d02:4725:4e0f:6eff:fef6:70b9]) by smtp.gmail.com with ESMTPSA id u73sm15462779pfi.105.2017.06.11.17.19.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Jun 2017 17:19:52 -0700 (PDT) In-Reply-To: <87k24i2rev.fsf@netris.org> (Mark H. Weaver's message of "Sun, 11 Jun 2017 16:36:08 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::236 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13819 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Mark, Thank you for the detailed response! I learn something new every day. Mark H Weaver 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: =2D-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 =3D 1 $2 =3D 2 scheme@(guile-user)> (define g (compose list f)) scheme@(guile-user)> (g) $3 =3D (1 2) scheme@(guile-user)> (list (f)) $4 =3D (1) scheme@(guile-user)>=20 =2D-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. =2D-=20 Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAlk93iMACgkQ3UCaFdgi Rp0HVBAAgTdOl7v/v2g9NDao1PF1sJ4dsdKC547hn/PaCLfMzJxoBtL2o3mPqkEJ /W/T8NF6w7bCvgtZbQK/Y90MUTolTvk5e38aD5zLqw58YbcupV5j2/7P8KyBA6kc K0jBUSXXtUmdmUvYABrFR/TtADPSiZC7Q4zmv8zPWj8jzRte6VYmDuPeTTKHoGI1 8AUMUArII1GxIrEndlnHisQM9D4Hpj4NEq5+T4kZMvQ+mlLqb+7mOerCljw9pJDU YbQ50RX4Ze5Q5gawd7V5cyalQkXNs1yzkRs5c7EqIARULOzB8yWad5N29F29CwyL FXy1Eg2c+Jjm2tCUIZARMBxFj+d1RK7q8UYewM1Pit9VHfrvU++W+cLiH37CndU9 1g6wy7twOIs0V7kDRlCA8HlQf5MSbg9wEffn/bhsDmTds2hCh6718JL2nO4O8dZB Hm8SPkMnwbMQih5LZyaEe+sdl5dsNrsaQ2c/xCOJO03ccDLHZHttYL8IGibTIdWo 8X/asSf1De2KnJgpBHY2N4vHJ2tB/VJxmgXCPymokcQ1m4MiMT3bvPlrcCTZyc5K H++YP/4833A5VlmByLPXp0IJWPKdKZmqR6DnmkQr6zsteAEGffC9lEDDqQXvSSaq MBuhapBO7c9O4pIz1RZc5hUjbDBiYwYpHCCo9Sodxf+6vSYNUEQ= =Rvud -----END PGP SIGNATURE----- --=-=-=--