From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: How do I make a manifest file that installs a specific version of a dependency? Date: Mon, 13 Mar 2017 10:20:03 +0100 Message-ID: <87lgs9a5z0.fsf@gnu.org> References: <87shmi17wy.fsf@gnu.org> <87mvcpy4in.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnM9C-0008Hn-49 for help-guix@gnu.org; Mon, 13 Mar 2017 05:20:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnM98-00063z-3G for help-guix@gnu.org; Mon, 13 Mar 2017 05:20:10 -0400 In-Reply-To: <87mvcpy4in.fsf@gmail.com> (Chris Marusich's message of "Mon, 13 Mar 2017 01:17:36 -0700") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Chris Marusich Cc: help-guix@gnu.org, Zachary Kanfer Chris Marusich skribis: > Just for fun, I tried running some commands in a REPL. I wanted to find > out why the "list" procedure was being used here. What I saw was this: > > scheme@(guile-user)> (specification->package+output "icedtea@2.6.9:jdk") > $6 =3D # > $7 =3D "jdk" > scheme@(guile-user)> (list (specification->package+output "icedtea@2.6.9:= jdk")) > $8 =3D (#) > scheme@(guile-user)> (map (compose list specification->package+output) '(= "icedtea@2.6.9:jdk")) > $9 =3D ((# "jdk"= )) > scheme@(guile-user)> > > Why does the string "jdk" appear in $9 but not in $8? It looks like the > list procedure ignored the second value (the "jdk" string) when > producing $8, but not when producing $9. Is that true? Why? =E2=80=98specification->package+output=E2=80=99 returns two values; in Sche= me that really means returning two values, and this is completely different from returning a two-element list or anything like that (info "(guile) Multiple Values"). Guile automatically truncates multiple-value returns: if a procedure returns, say, two values but its continuation expects only one, then the second return value is dismissed. Like this: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (values 1 2) $2 =3D 1 $3 =3D 2 ;the REPL lists all the return values scheme@(guile-user)> (list (values 1 2)) $4 =3D (1) ;continuation of the =E2=80=98values=E2=80=99 form expects one = value --8<---------------cut here---------------end--------------->8--- =E2=80=98call-with-values=E2=80=99 is the primitive that allows you to retr= ieve all the return values: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (call-with-values (lambda () (values 1 2)) list) ;continuation expects any number of values $5 =3D (1 2) scheme@(guile-user)> (call-with-values (lambda () (values 1 2)) (lambda (a b) ;continuation expects two values (list b a))) $6 =3D (2 1) --8<---------------cut here---------------end--------------->8--- I must say that this is more complicated than I=E2=80=99d like in the case = of =E2=80=98specification->package+output=E2=80=99. HTH! Ludo=E2=80=99.