From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: Merging guix.el Date: Wed, 03 Sep 2014 00:22:38 +0400 Message-ID: <87oauxkc1d.fsf@gmail.com> References: <874mx3z9h2.fsf@gnu.org> <87fvgim60p.fsf@gmail.com> <87mwaobxbo.fsf@gnu.org> <87tx4wlbis.fsf@gmail.com> <87wq9s4bqy.fsf@gnu.org> <87iolbkvbc.fsf@gmail.com> <87lhq466xx.fsf@gnu.org> <8761h7lpal.fsf@gmail.com> <87y4u38rso.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOubG-0005ZC-E5 for guix-devel@gnu.org; Tue, 02 Sep 2014 16:22:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOub9-00048W-Pl for guix-devel@gnu.org; Tue, 02 Sep 2014 16:22:46 -0400 In-Reply-To: <87y4u38rso.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 01 Sep 2014 14:10:47 +0200") 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-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: Guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (2014-09-01 16:10 +0400) wrote: > Alex Kost skribis: > >> Ludovic Court=C3=A8s (2014-08-31 18:59 +0400) wrote: > > [...] > >>> The key is =E2=80=98vhash-fold*=E2=80=99 (info "(guile) VHashes"). It = allows you to >>> traverse all the entries associated with a given key: >>> >>> scheme@(guile-user)> (vhash-cons '("guile" "2.0") 'foo >>> (vhash-cons '("guile" "2.0") 'bar >>> vlist-null)) >>> $12 =3D # >>> scheme@(guile-user)> (vhash-fold* cons '() '("guile" "2.0") $12) >>> $13 =3D (bar foo) >>> >>> I think that answers your question, right? >> >> Absolutely; sorry for missing that feature. But will it be a real >> optimization? If I want to get information for all packages, I have to >> perform =E2=80=98vhash-fold*=E2=80=99 on =E2=80=98manifest-name->entry= =E2=80=99 vhash for each package >> (to get installed outputs). With hash-table, I just need to use >> =E2=80=98hash-ref=E2=80=99 for each package. > > =E2=80=98vhash-fold*=E2=80=99 iterates only on the values associated with= the given key; > it has time complexity linear in the number of values associated with > that key. So no worries here (and again, 90% of the time there=E2=80=99l= l be > exactly one package corresponding to a name/version pair.) Ah, OK then. (I still have some worries but it's just paranoia apparently). >> Also I need to fold over unique names (I use =E2=80=98fold-manifest-entr= ies=E2=80=99 >> from =E2=80=9Cguix-main.scm=E2=80=9D for that) and I have no idea how vh= ash can help >> there. > > Would =E2=80=98vlist-fold=E2=80=99 work? > > scheme@(guile-user)> (vhash-cons 'a 1 (vhash-cons 'b 2 (vhash-cons 'a 3 v= list-null))) > $2 =3D # > scheme@(guile-user)> (vlist-fold cons '() $2) > $3 =3D ((a . 3) (b . 2) (a . 1)) Sorry, I don't see how it could work. Here is an example: --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=sample.scm ;; What I currently have is a hash-table like this one: (define table (make-hash-table 3)) (hash-set! table 'a '(1 2 3)) (hash-set! table 'b '(4)) (hash-set! table 'c '(5 6)) ;; And I can easily fold through unique keys like this: (hash-fold (lambda (key entries res) (cons (cons key (apply + entries)) res)) '() table) ; => ((c . 11) (b . 4) (a . 6)) ;; What you suggest is a vhash like this: (define vhash (vhash-cons 'a 1 (vhash-cons 'a 2 (vhash-cons 'a 3 (vhash-cons 'b 4 (vhash-cons 'c 5 (vhash-cons 'c 6 vlist-null))))))) ;; But how can I fold through unique keys there? --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [...] > I=E2=80=99ll check the doc later today, but it seems this is essentially = ready > for merging, no? Yes, If you don't mind that I'm still using hash-tables, I think it can be merged. > When we merge, would you like to rewrite history and make the whole > thing appear as a single =E2=80=9Cperfect=E2=80=9D commit, or just merge = =E2=80=98emacs-ui=E2=80=99 into > =E2=80=98master=E2=80=99? (I often do the former, but I=E2=80=99m fine w= ith the latter here.) I don't have a preference here. I can do a single commit if it is more appropriate. Would the following commit message be OK? --8<---------------cut here---------------start------------->8--- Add Emacs user interface. * configure.ac (emacsuidir): New variable. (AC_CONFIG_FILES): Add 'emacs/guix-init.el', 'emacs/guix-helper.scm'. * Makefile.am: Include 'emacs.am'. * emacs.am: New file. * doc/emacs.texi: New file. * doc/guix.texi: Include 'emacs.texi'. * emacs/guix-backend.el: New file. * emacs/guix-base.el: New file. * emacs/guix-helper.scm.in: New file. * emacs/guix-history.el: New file. * emacs/guix-info.el: New file. * emacs/guix-init.el.in: New file. * emacs/guix-list.el: New file. * emacs/guix-main.scm: New file. * emacs/guix-utils.el: New file. * emacs/guix.el: New file. --8<---------------cut here---------------end--------------->8--- --=-=-=--