[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] emacs: Add 'guix-package-from-file' command.
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH 2/2] emacs: Add 'guix-package-from-file' command. |
Date: |
Mon, 09 May 2016 22:29:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Alex Kost <address@hidden> 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’.