all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: Merging guix.el
Date: Wed, 03 Sep 2014 00:22:38 +0400	[thread overview]
Message-ID: <87oauxkc1d.fsf@gmail.com> (raw)
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")

[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]

Ludovic Courtès (2014-09-01 16:10 +0400) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2014-08-31 18:59 +0400) wrote:
>
> [...]
>
>>> The key is ‘vhash-fold*’ (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 = #<vhash 39240a0 2 pairs>
>>> scheme@(guile-user)> (vhash-fold* cons '() '("guile" "2.0") $12)
>>> $13 = (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 ‘vhash-fold*’ on ‘manifest-name->entry’ vhash for each package
>> (to get installed outputs).  With hash-table, I just need to use
>> ‘hash-ref’ for each package.
>
> ‘vhash-fold*’ 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’ll 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 ‘fold-manifest-entries’
>> from “guix-main.scm” for that) and I have no idea how vhash can help
>> there.
>
> Would ‘vlist-fold’ work?
>
> scheme@(guile-user)> (vhash-cons 'a 1 (vhash-cons 'b 2 (vhash-cons 'a 3 vlist-null)))
> $2 = #<vhash 26fd3a0 3 pairs>
> scheme@(guile-user)> (vlist-fold cons '() $2)
> $3 = ((a . 3) (b . 2) (a . 1))

Sorry, I don't see how it could work.  Here is an example:


[-- Attachment #2: sample.scm --]
[-- Type: text/plain, Size: 676 bytes --]

;; 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?

[-- Attachment #3: Type: text/plain, Size: 1317 bytes --]


[...]

> I’ll 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 “perfect” commit, or just merge ‘emacs-ui’ into
> ‘master’?  (I often do the former, but I’m fine with 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---


  reply	other threads:[~2014-09-02 20:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-23 12:17 Merging guix.el Ludovic Courtès
2014-08-24  6:59 ` Alex Kost
2014-08-25  8:23   ` Ludovic Courtès
2014-08-25 12:31     ` Alex Kost
2014-08-25 22:03       ` Ludovic Courtès
2014-08-26  4:14         ` Alex Kost
2014-08-27 13:11 ` Alex Kost
2014-08-28 12:41   ` Ludovic Courtès
2014-08-28 18:22     ` Alex Kost
2014-08-28 20:09       ` Ludovic Courtès
2014-08-29 18:24         ` Alex Kost
2014-08-31 14:59           ` Ludovic Courtès
2014-09-01  8:26             ` Alex Kost
2014-09-01 12:10               ` Ludovic Courtès
2014-09-02 20:22                 ` Alex Kost [this message]
2014-09-03  7:09                   ` Ludovic Courtès
2014-09-03 20:53                     ` Alex Kost
2014-09-01 22:28               ` Ludovic Courtès
2014-09-02 20:22                 ` Alex Kost
2014-09-02 21:13                   ` Ludovic Courtès
2014-09-02 20:22             ` Alex Kost
2014-09-02 21:09               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oauxkc1d.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.