From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 2/2] emacs: Add 'guix-package-from-file' command. Date: Mon, 09 May 2016 22:29:22 +0200 Message-ID: <87r3dbnffh.fsf@gnu.org> References: <1462704662-18972-1-git-send-email-alezost@gmail.com> <1462704662-18972-3-git-send-email-alezost@gmail.com> <87d1ow4clh.fsf@gnu.org> <87zirzocym.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]:60733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azro5-0007Tb-8Z for guix-devel@gnu.org; Mon, 09 May 2016 16:29:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azro0-0002A6-Vy for guix-devel@gnu.org; Mon, 09 May 2016 16:29:33 -0400 In-Reply-To: <87zirzocym.fsf@gmail.com> (Alex Kost's message of "Mon, 09 May 2016 11:25:05 +0300") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Alex Kost Cc: guix-devel@gnu.org Alex Kost skribis: > Ludovic Court=C3=A8s (2016-05-08 21:40 +0300) wrote: [...] >> =E2=80=A6 by wrapping =E2=80=98vhash-consq=E2=80=99 in =E2=80=98delay=E2= =80=99. > > =E2=80=A6 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, =E2=80=98register-package=E2=80=99 would turn = =E2=80=98table=E2=80=99 into a self-reference, hence the stack overflow. >> To avoid =E2=80=98set!=E2=80=99 above, the options that come to mind wou= ld 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=E2=80=99t = 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=E2=80=99t like it either. Thanks! Ludo=E2=80=99.