all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Alex Kost <alezost@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 2/2] emacs: Add 'guix-package-from-file' command.
Date: Mon, 09 May 2016 22:29:22 +0200	[thread overview]
Message-ID: <87r3dbnffh.fsf@gnu.org> (raw)
In-Reply-To: <87zirzocym.fsf@gmail.com> (Alex Kost's message of "Mon, 09 May 2016 11:25:05 +0300")

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2016-05-08 21:40 +0300) wrote:

[...]

>> … by wrapping ‘vhash-consq’ in ‘delay’.
>
> … I tried it, but I got an error I don't know what to do with:
>
>   Throw to key `vm-error' with args `(vm-run "VM: Stack overflow" ())'.

I needs to be changed like this:

--8<---------------cut here---------------start------------->8---
(define-values (package-by-address
                register-package)
  (let ((table (delay (fold-packages
                       (lambda (package table)
                         (vhash-consq (object-address package)
                                      package table))
                       vlist-null))))
    (values
     (lambda (address)
       "Return package by its object ADDRESS."
       (match (vhash-assq address (force table))
         ((_ . package) package)
         (_ #f)))
     (lambda (package)
       "Register PACKAGE by its 'object-address', so that later
'package-by-address' can be used to access it."
       (let ((table (force table)))
         (set! table
           (delay (vhash-consq (object-address package)
                               package table))))))))
--8<---------------cut here---------------end--------------->8---

In the example you posted, ‘register-package’ would turn ‘table’ into a
self-reference, hence the stack overflow.

>> To avoid ‘set!’ above, the options that come to mind would be:
>>
>>   1. To not provide M-x guix-package-from-file and instead provide, say,
>>      M-x guix-install-package-from-file.  That way, we wouldn’t need to
>>      remember the package.
>
> I don't like this solution.  With "M-x guix-package-from-file" you get a
> full-featured *Guix Package Info* buffer, where you can not only install
> the package, but download its source, look at its license, inputs,
> etc. (and soon it will be possible just to build it without installing).

Yeah, I mentioned it for completeness but I don’t like it either.

Thanks!

Ludo’.

  reply	other threads:[~2016-05-09 20:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-08 10:51 [PATCH 0/2] emacs: Add "M-x guix-package-from-file Alex Kost
2016-05-08 10:51 ` [PATCH 1/2] emacs: main: Remove top-level package tables Alex Kost
2016-05-08 16:54   ` Ludovic Courtès
2016-05-08 10:51 ` [PATCH 2/2] emacs: Add 'guix-package-from-file' command Alex Kost
2016-05-08 18:40   ` Ludovic Courtès
2016-05-09  8:25     ` Alex Kost
2016-05-09 20:29       ` Ludovic Courtès [this message]
2016-05-10  9:09         ` Alex Kost

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

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

  git send-email \
    --in-reply-to=87r3dbnffh.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=alezost@gmail.com \
    --cc=guix-devel@gnu.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.