guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/1] Factor out a common pattern into a procedure.


From: John Darrington
Subject: Re: [PATCH 1/1] Factor out a common pattern into a procedure.
Date: Sun, 19 Oct 2014 09:40:36 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Oct 18, 2014 at 10:03:42PM -0400, Ian Denhardt wrote:
     The procedure version-take-api extracts the "major.minor" part of
     version strings; previously this was handled by an expression common to
     several packages.
     
     diff --git a/guix/utils.scm b/guix/utils.scm
     index 6392914..a179f6b 100644
     --- a/guix/utils.scm
     +++ b/guix/utils.scm
     @@ -2,6 +2,7 @@
      ;;; Copyright ?? 2012, 2013, 2014 Ludovic Court??s <address@hidden>
      ;;; Copyright ?? 2013 Mark H Weaver <address@hidden>
      ;;; Copyright ?? 2014 Eric Bavier <address@hidden>
     +;;; Copyright ?? 2014 Ian Denhardt <address@hidden>
      ;;;
      ;;; This file is part of GNU Guix.
      ;;;
     @@ -64,6 +65,7 @@
                  %current-system
                  %current-target-system
                  version-compare
     +            version-take-api
                  version>?
                  guile-version>?
                  package-name->name+version
     @@ -518,6 +520,11 @@ or '= when they denote equal versions."
                    ((negative? result) '<)
                    (else '=))))))
      
     +(define (version-take-api version-string)
     +  "Return \"<major>.<minor>\", where major and minor are the major and
     +minor version numbers from version-string."
     +  (string-join (take (string-split version-string #\.) 2) "."))
     +
      (define (version>? a b)
        "Return #t when A denotes a newer version than B."
        (eq? '> (version-compare a b)))


It seems likely to me, that sometime we'll need the number of fields to be 
parameterised,
instead of hard coded at 2  (for example lynx has a directory component with 3 
fields in its URL)

Also I don't understand the significnace of the name version-take-api What does 
API have to
do with anything?

How about something like (string-take-fields "1.22.3.04.5" 3) which would 
return "1.22.3"

Possibly an optional argument specifying the separator might be useful too.


J'


-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]