From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Bavier Subject: Re: [PATCH] list-packages: Display package usage count. Date: Sun, 26 Oct 2014 13:23:05 -0500 Message-ID: <87lho2y9km.fsf@gmail.com> References: <87wq7uu0ga.fsf@member.fsf.org> <87siibstyh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiSQn-0001gg-1l for guix-devel@gnu.org; Sun, 26 Oct 2014 14:20:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XiSQh-0000co-Jx for guix-devel@gnu.org; Sun, 26 Oct 2014 14:20:44 -0400 In-reply-to: <87siibstyh.fsf@gnu.org> 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: =?utf-8?Q?Ludovic_Court=C3=A8s?= Cc: guix-devel@gnu.org Ludovic Courtès writes: > Eric Bavier skribis: > >> + (define (users package) >> + (let ((n (length (package-transitive-dependents >> + (find-packages-by-name* (package-name package) >> + (package-version package)))))) > > Why not just (package-transitive-dependents package)? Because that would not accurately count the "true" number of dependents. It is constistent with the discussion and script I attached at https://lists.gnu.org/archive/html/guix-devel/2014-10/msg00196.html >> -(define find-packages-by-name >> +(define (find-packages fold) >> (let ((packages (delay >> - (fold-packages (lambda (p r) >> - (vhash-cons (package-name p) p r)) >> - vlist-null)))) >> + (fold (lambda (p r) >> + (vhash-cons (package-name p) p r)) >> + vlist-null)))) >> (lambda* (name #:optional version) >> "Return the list of packages with the given NAME. If VERSION is not #f, >> then only return packages whose version is equal to VERSION." >> @@ -207,6 +208,9 @@ then only return packages whose version is equal to VERSION." >> matching) >> matching))))) >> >> +(define find-packages-by-name (find-packages fold-packages)) >> +(define find-packages-by-name* (find-packages fold-packages*)) > > ‘fold-packages*’ is the variant that also looks for private packages, > right? (It’s from one of the recent patches that hasn’t made it yet.) That's correct. -- Eric Bavier Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html