unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Chris Marusich <cmmarusich@gmail.com>
Cc: help-guix@gnu.org, Zachary Kanfer <zkanfer@gmail.com>
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	[thread overview]
Message-ID: <87lgs9a5z0.fsf@gnu.org> (raw)
In-Reply-To: <87mvcpy4in.fsf@gmail.com> (Chris Marusich's message of "Mon, 13 Mar 2017 01:17:36 -0700")

Chris Marusich <cmmarusich@gmail.com> 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 = #<package icedtea@2.6.9 gnu/packages/java.scm:347 39a6000>
> $7 = "jdk"
> scheme@(guile-user)> (list (specification->package+output "icedtea@2.6.9:jdk"))
> $8 = (#<package icedtea@2.6.9 gnu/packages/java.scm:347 39a6000>)
> scheme@(guile-user)> (map (compose list specification->package+output) '("icedtea@2.6.9:jdk"))
> $9 = ((#<package icedtea@2.6.9 gnu/packages/java.scm:347 39a6000> "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?

‘specification->package+output’ returns two values; in Scheme 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 = 1
$3 = 2    ;the REPL lists all the return values
scheme@(guile-user)> (list (values 1 2))
$4 = (1)  ;continuation of the ‘values’ form expects one value
--8<---------------cut here---------------end--------------->8---

‘call-with-values’ is the primitive that allows you to retrieve 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 = (1 2)
scheme@(guile-user)> (call-with-values (lambda () (values 1 2))
		       (lambda (a b)  ;continuation expects two values
			 (list b a)))
$6 = (2 1)
--8<---------------cut here---------------end--------------->8---

I must say that this is more complicated than I’d like in the case of
‘specification->package+output’.

HTH!

Ludo’.

      reply	other threads:[~2017-03-13  9:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-12  5:55 How do I make a manifest file that installs a specific version of a dependency? Zachary Kanfer
2017-03-12 21:50 ` Ludovic Courtès
2017-03-12 23:50   ` Zachary Kanfer
2017-03-13  8:24     ` Ludovic Courtès
2017-03-13  8:17   ` Chris Marusich
2017-03-13  9:20     ` Ludovic Courtès [this message]

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://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgs9a5z0.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=cmmarusich@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=zkanfer@gmail.com \
    /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).