From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Merging guix.el Date: Sun, 31 Aug 2014 16:59:38 +0200 Message-ID: <87lhq466xx.fsf@gnu.org> 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> 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]:33026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XO8ex-0007rn-FD for guix-devel@gnu.org; Sun, 31 Aug 2014 13:11:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XO8es-0005h8-R6 for guix-devel@gnu.org; Sun, 31 Aug 2014 13:11:23 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:52865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XO8es-0005h2-FM for guix-devel@gnu.org; Sun, 31 Aug 2014 13:11:18 -0400 In-Reply-To: <87iolbkvbc.fsf@gmail.com> (Alex Kost's message of "Fri, 29 Aug 2014 22:24:55 +0400") 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: Alex Kost Cc: Guix-devel Alex Kost skribis: > Ludovic Court=C3=A8s (2014-08-29 00:09 +0400) wrote: [...] > OK, I made "emacs.am" and modified "configure.ac" and "Makefile.am" (I > pushed 2 new commits to =E2=80=9Cemacs-ui=E2=80=9D branch). Is there any= thing else to > be done in a build part? No, that looks good to me. [...] >>> I think it's a good idea, but if that "name" is just a package name, >>> I can't use this optimization: I need to define entries by >>> "name+version". >> >> Yes, makes sense. So that =E2=80=98name->entries=E2=80=99 field would m= ap a package >> name to a list of entries; in the most common case, there=E2=80=99ll be = just one >> entry anyway. How does that sound? [...] > Also I'm still not sure about the name =E2=80=98manifest-name->entries=E2= =80=99 (or > =E2=80=98manifest-name->entry=E2=80=99), as this function returns a vhash= , it does not > transform a name into a list of entries. It may be confusing, no? That would be only for internal use anyway, but if you prefer =E2=80=98manifest-table=E2=80=99 would do as well. [...] >>>> Given that =E2=80=98set-packages!=E2=80=99 has only on call site, what= about removing >>>> it, and instead writing directly: >>>> >>>> (define %packages >>>> (fold-packages ... vlist-null)) >>>> >>>> (define %package-count >>>> (length %packages)) >>>> >>>> (define %package-table >>>> (vlist-fold ...)) >>>> >>>> It=E2=80=99s also best to prefix global variable names with =E2=80=98%= =E2=80=99. > > I recalled why I used that ugly =E2=80=98set-packages!=E2=80=99: I just d= idn't want to > count packages again (i.e. to use =E2=80=98length=E2=80=99) for hash-tabl= e, so I > combined setting =E2=80=98packages=E2=80=99 variable with counting. OK, but even when there=E2=80=99s 1M packages, =E2=80=98length=E2=80=99 is = still going to be almost instantaneous, so no worries IMO. ;-) >> I would make %package-table a vhash instead of a hash table: >> >> (define %package-table >> (vlist-fold (lambda (elem result) >> (match elem >> ((name . package) >> (vhash-cons (cons (package-name package) >> (package-version package)) >> package >> (if (vhash-assq name result) >> ...))))) >> vlist-null >> %packages)) > > ... I left hash table, because I still don't understand how to use vhash > for that: a name+version key should give a list of all matching > packages, but AFAIU your variant would just replace one package with > another (with the same name+version). The key is =E2=80=98vhash-fold*=E2=80=99 (info "(guile) VHashes"). It allo= ws you to traverse all the entries associated with a given key: --8<---------------cut here---------------start------------->8--- 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) --8<---------------cut here---------------end--------------->8--- I think that answers your question, right? > As for =E2=80=98set-current-manifest-maybe!=E2=80=99, I'm afraid it can't= be deleted. I > found that I put it in some places where it shouldn't appear and I fixed > that, but it still stays in functions returning =E2=80=9Cpackage informat= ion=E2=80=9D > for the elisp side (for info/list buffers). Currently I can't invent a > way how to get rid of this function completely. I think the profile=E2=80=99s file name could be kept on the elisp side, and passed to the Scheme code, which wouldn=E2=80=99t need to keep it in a glob= al variable. That would also allow guix.el to be used on profiles other than the default one. That said, we can look into it later if you prefer. WDYT? Thanks! Ludo=E2=80=99.