[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] emacs: Add 'guix-package-from-file' command.
From: |
Alex Kost |
Subject: |
Re: [PATCH 2/2] emacs: Add 'guix-package-from-file' command. |
Date: |
Tue, 10 May 2016 12:09:19 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Ludovic Courtès (2016-05-09 23:29 +0300) wrote:
> 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:
>
> (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))))))))
>
> In the example you posted, ‘register-package’ would turn ‘table’ into a
> self-reference, hence the stack overflow.
Heh, so simple, thanks a lot! I used this variant and committed this
patch, thanks again.
--
Alex