unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19  2:18 [PATCH 0/1] *** SUBJECT HERE *** Ian Denhardt
@ 2014-10-19  2:03 ` Ian Denhardt
  2014-10-19  7:40   ` John Darrington
  2014-10-19 14:57   ` Mark H Weaver
  2014-10-19  2:29 ` [PATCH 0/1] *** SUBJECT HERE *** Ian Denhardt
  1 sibling, 2 replies; 11+ messages in thread
From: Ian Denhardt @ 2014-10-19  2:03 UTC (permalink / raw)
  To: guix-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 12830 bytes --]

The procedure version-take-api extracts the "major.minor" part of
version strings; previously this was handled by an expression common to
several packages.

* guix/utils.scm (version-take-api): New procedure
* gnu/packages/backup.scm (duplicity): Use version-take-api.
* gnu/packages/cmake.scm (cmake): Likewise.
* gnu/packages/gnome.scm (libbonobo, libbonoboui): Likewise.
* gnu/packages/gnutls.scm (gnutls): Likewise.
* gnu/packages/mail.scm (gmime): Likewise.
* gnu/packages/mpd.scm (mpd): Likewise.
* gnu/packages/mpi.scm (openmpi): Likewise.
---
 gnu/packages/backup.scm |  7 ++++---
 gnu/packages/cmake.scm  | 11 +++++------
 gnu/packages/gnome.scm  | 10 +++++-----
 gnu/packages/gnutls.scm |  8 ++++----
 gnu/packages/mail.scm   |  9 ++++-----
 gnu/packages/mpd.scm    |  6 +++---
 gnu/packages/mpi.scm    |  8 ++++----
 guix/utils.scm          |  7 +++++++
 8 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index 1aef75e..328d3d8 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,6 +21,7 @@
   #:use-module (guix packages)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build utils)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
@@ -38,8 +40,7 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages rsync)
   #:use-module (gnu packages ssh)
-  #:use-module (gnu packages xml)
-  #:use-module (srfi srfi-1))
+  #:use-module (gnu packages xml))
 
 (define-public duplicity
   (package
@@ -49,7 +50,7 @@
      (origin
       (method url-fetch)
       (uri (string-append "https://code.launchpad.net/duplicity/"
-                          (string-join (take (string-split version #\.) 2) ".")
+                          (version-take-api version)
                           "-series/" version "/+download/duplicity-"
                           version ".tar.gz"))
       (sha256
diff --git a/gnu/packages/cmake.scm b/gnu/packages/cmake.scm
index 2c20c73..5b4f123 100644
--- a/gnu/packages/cmake.scm
+++ b/gnu/packages/cmake.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,14 +23,14 @@
   #:use-module ((guix licenses) #:select (bsd-3))
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages)
   #:use-module (gnu packages backup)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages file)
-  #:use-module (gnu packages xml)
-  #:use-module (srfi srfi-1))
+  #:use-module (gnu packages xml))
 
 (define-public cmake
   (package
@@ -39,8 +40,7 @@
              (method url-fetch)
              (uri (string-append
                    "http://www.cmake.org/files/v"
-                   (string-join (take (string-split version #\.) 2)
-                                ".")
+                   (version-take-api version)
                    "/cmake-" version ".tar.gz"))
              (sha256
               (base32 "11q21vyrr6c6smyjy81k2k07zmn96ggjia9im9cxwvj0n88bm1fq"))
@@ -91,8 +91,7 @@
                                "--mandir=share/man"
                                ,(string-append
                                  "--docdir=share/doc/cmake-"
-                                 (string-join (take (string-split version #\.) 2)
-                                              "."))))))
+                                 (version-take-api version))))))
                    %standard-phases)))))
     (inputs
      `(("file"       ,file)
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index bbb3053..f0f1969 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages)
   #:use-module (gnu packages bison)
@@ -42,8 +44,7 @@
   #:use-module (gnu packages xml)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages compression)
-  #:use-module (gnu packages xorg)
-  #:use-module (srfi srfi-1))
+  #:use-module (gnu packages xorg))
 
 (define-public brasero
   (package
@@ -706,8 +707,7 @@ featuring mature C, C++ and Python bindings.")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://gnome/sources/" name "/"
-                                  (string-join (take (string-split version #\.) 2)
-                                               ".")
+                                  (version-take-api version)
                                   "/" name "-" version ".tar.bz2"))
               (sha256
                (base32 "0swp4kk6x7hy1rvd1f9jba31lvfc6qvafkvbpg9h0r34fzrd8q4i"))
@@ -1077,7 +1077,7 @@ widgets built in the loading process.")
               (method url-fetch)
               (uri (string-append
                     "mirror://gnome/sources/" name "/"
-                    (string-join (take (string-split version #\.) 2) ".")
+                    (version-take-api version)
                     "/" name "-" version ".tar.bz2"))
               (sha256
                (base32
diff --git a/gnu/packages/gnutls.scm b/gnu/packages/gnutls.scm
index 3e4fa63..8c295fc 100644
--- a/gnu/packages/gnutls.scm
+++ b/gnu/packages/gnutls.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,7 @@
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module ((gnu packages compression) #:prefix guix:)
   #:use-module (gnu packages)
@@ -29,8 +31,7 @@
   #:use-module (gnu packages perl)
   #:use-module (gnu packages which)
   #:use-module (gnu packages texinfo)
-  #:use-module (gnu packages pkg-config)
-  #:use-module (srfi srfi-1))
+  #:use-module (gnu packages pkg-config))
 
 (define-public libtasn1
   (package
@@ -69,8 +70,7 @@ specifications.")
               ;; Note: Releases are no longer on ftp.gnu.org since the
               ;; schism (after version 3.1.5).
               (string-append "mirror://gnupg/gnutls/v"
-                             (string-join (take (string-split version #\.) 2)
-                                          ".")
+                             (version-take-api version)
                              "/gnutls-" version ".tar.xz"))
              (sha256
               (base32
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 2a742cd..ce89ce4 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,9 +50,9 @@
                 #:select (gpl2 gpl2+ gpl3+ lgpl2.1+ lgpl3+))
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
-  #:use-module (guix build-system python)
-  #:use-module (srfi srfi-1))
+  #:use-module (guix build-system python))
 
 (define-public mailutils
   (package
@@ -192,9 +193,7 @@ operating systems.")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://gnome/sources/gmime/"
-                                  (string-join (take (string-split version #\.)
-                                                     2)
-                                               ".")
+                                  (version-take-api version)
                                   "/gmime-" version ".tar.xz"))
               (sha256
                (base32
diff --git a/gnu/packages/mpd.scm b/gnu/packages/mpd.scm
index 0accc5e..35f7b04 100644
--- a/gnu/packages/mpd.scm
+++ b/gnu/packages/mpd.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 David Thompson <dthompson2@worcester.edu>
 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,11 +20,11 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages mpd)
-  #:use-module (srfi srfi-1)
   #:use-module (gnu packages)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages avahi)
   #:use-module (gnu packages compression)
@@ -72,8 +73,7 @@ interfacing MPD in the C, C++ & Objective C languages.")
               (method url-fetch)
               (uri
                (string-append "http://musicpd.org/download/mpd/"
-                              (string-join (take (string-split
-                                                  version #\.) 2) ".")
+                              (version-take-api version)
                               "/mpd-" version ".tar.gz"))
               (sha256
                (base32
diff --git a/gnu/packages/mpi.scm b/gnu/packages/mpi.scm
index e7919bc..b2cade0 100644
--- a/gnu/packages/mpi.scm
+++ b/gnu/packages/mpi.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,6 +23,7 @@
   #:use-module ((guix licenses)
                 #:hide (expat))
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages)
   #:use-module (gnu packages gcc)
@@ -32,8 +34,7 @@
   #:use-module (gnu packages xml)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages pkg-config)
-  #:use-module (gnu packages valgrind)
-  #:use-module (srfi srfi-1))
+  #:use-module (gnu packages valgrind))
 
 (define-public hwloc
   (package
@@ -88,8 +89,7 @@ bind processes, and much more.")
      (origin
       (method url-fetch)
       (uri (string-append "http://www.open-mpi.org/software/ompi/v"
-                          (string-join (take (string-split version #\.) 2)
-                                       ".")
+                          (version-take-api version)
                           "/downloads/openmpi-" version ".tar.bz2"))
       (sha256
        (base32
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 <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;;
 ;;; 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)))
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 0/1] *** SUBJECT HERE ***
@ 2014-10-19  2:18 Ian Denhardt
  2014-10-19  2:03 ` [PATCH 1/1] Factor out a common pattern into a procedure Ian Denhardt
  2014-10-19  2:29 ` [PATCH 0/1] *** SUBJECT HERE *** Ian Denhardt
  0 siblings, 2 replies; 11+ messages in thread
From: Ian Denhardt @ 2014-10-19  2:18 UTC (permalink / raw)
  To: guix-devel

Prompted by Mark Weaver's feedback on the ntp package patch earlier today, I
refactored the pattern:

    (string-join (take (string-split version #\.) 2)
                 ".")

Into a common procedure:

    (version-take-api version)

..and modified the existing package recepies accordingly.

Ian Denhardt (1):
  Factor out a common pattern into a procedure.

 gnu/packages/backup.scm |  7 ++++---
 gnu/packages/cmake.scm  | 11 +++++------
 gnu/packages/gnome.scm  | 10 +++++-----
 gnu/packages/gnutls.scm |  8 ++++----
 gnu/packages/mail.scm   |  9 ++++-----
 gnu/packages/mpd.scm    |  6 +++---
 gnu/packages/mpi.scm    |  8 ++++----
 guix/utils.scm          |  7 +++++++
 8 files changed, 36 insertions(+), 30 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/1] *** SUBJECT HERE ***
  2014-10-19  2:18 [PATCH 0/1] *** SUBJECT HERE *** Ian Denhardt
  2014-10-19  2:03 ` [PATCH 1/1] Factor out a common pattern into a procedure Ian Denhardt
@ 2014-10-19  2:29 ` Ian Denhardt
  1 sibling, 0 replies; 11+ messages in thread
From: Ian Denhardt @ 2014-10-19  2:29 UTC (permalink / raw)
  To: guix-devel

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

Quoting Ian Denhardt (2014-10-18 22:18:00)
> ...

Ack, sorry for the goof on the subject.

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABAgAGBQJUQyHtAAoJEPZUuMfUyjy4NY4QAO00L3ZmAHMLFw+TLNj6m2FJ
o38rTcs1LBYWURkQ7jXtyrt4Wo5C2xmjbhByiG+FbY3No88pQwqCB8gzI3nK6T82
y/z0qO+Uz4W0OfTSI89zWs39A1BXyQCPDHIhOw6EYRP5G6lfB0CSepcLxHfmH0fU
fJxJMEDFt7M5bnkucW7pJ9/SzQaZbuhXXeX+XG725oZt9VgZgWKxntgFPZVHZi/h
yEcXzVeZH6+Kpfb0KCtKYoQghU/5mckYJ8H7d7s8FvHWgWy0jyh4wuoifwnM+aE2
5v4+2E/5vXKAVd/j9wMDKX5SAW6NPe6hDlXyYQvtRju469t2S9idcQuDPnZCsp0N
uPyW4dhxvC10U233jOHtJ3EGM0jIdVERz1JQtU+Sbfp8S5i/cwB4yNG3k2kTRWYo
MwidUK+1/0Ha3PCKhcP6wtMMVrXhcpPVk39nQcGfnpDkRZfuFps4M2ZYLyOpotm+
yozermXab/1r0WDt4HsUNs1cta8byX/gbtIZl1hjtxvVz/ShX3gSwfNU95V3GAJU
B+80BH4OQSQBCx1fKLjHZoDOEBhkcVwZrYxpFRiiYo4+SyZ0LqPI6WNVZVxfE8kc
DcBclBzIuf0b74bMRM47ddTlD/NMA23OlF76wT2xhRymNOncz1OscR/Ou7GFynd0
/1OKcaZCYzs1/DWu7gXd
=DOYt
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19  2:03 ` [PATCH 1/1] Factor out a common pattern into a procedure Ian Denhardt
@ 2014-10-19  7:40   ` John Darrington
  2014-10-19  9:39     ` Ludovic Courtès
  2014-10-19 18:15     ` Ian Denhardt
  2014-10-19 14:57   ` Mark H Weaver
  1 sibling, 2 replies; 11+ messages in thread
From: John Darrington @ 2014-10-19  7:40 UTC (permalink / raw)
  To: Ian Denhardt; +Cc: guix-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 2225 bytes --]

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 <ludo@gnu.org>
      ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
      ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
     +;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
      ;;;
      ;;; 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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19  7:40   ` John Darrington
@ 2014-10-19  9:39     ` Ludovic Courtès
  2014-10-19 14:43       ` Mark H Weaver
  2014-10-19 18:15     ` Ian Denhardt
  1 sibling, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2014-10-19  9:39 UTC (permalink / raw)
  To: John Darrington; +Cc: guix-devel

John Darrington <john@darrington.wattle.id.au> skribis:

> On Sat, Oct 18, 2014 at 10:03:42PM -0400, Ian Denhardt wrote:

Thanks, Ian, for working on it!

[...]

>      +(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"

Agreed.  What ‘version-prefix’, with the optional argument defaulting
to 2?

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

I think that’d be overkill.

Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19  9:39     ` Ludovic Courtès
@ 2014-10-19 14:43       ` Mark H Weaver
  2014-10-19 17:45         ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: Mark H Weaver @ 2014-10-19 14:43 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

ludo@gnu.org (Ludovic Courtès) writes:

> John Darrington <john@darrington.wattle.id.au> skribis:
>
>> How about something like (string-take-fields "1.22.3.04.5" 3) which would return "1.22.3"
>
> Agreed.  What ‘version-prefix’, with the optional argument defaulting
> to 2?

I also like 'version-prefix', although I'd favor making it a required
argument.  The improved code clarity is well worth two extra characters.
I don't feel strongly though.

>> Possibly an optional argument specifying the separator might be useful too.
>
> I think that’d be overkill.

Agreed.

     Mark

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19  2:03 ` [PATCH 1/1] Factor out a common pattern into a procedure Ian Denhardt
  2014-10-19  7:40   ` John Darrington
@ 2014-10-19 14:57   ` Mark H Weaver
  1 sibling, 0 replies; 11+ messages in thread
From: Mark H Weaver @ 2014-10-19 14:57 UTC (permalink / raw)
  To: Ian Denhardt; +Cc: guix-devel

Ian Denhardt <ian@zenhack.net> writes:

> 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 <ludo@gnu.org>
>  ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
>  ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
> +;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
>  ;;;
>  ;;; 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)))

Let's keep 'version-compare' and 'version>?' adjacent, in both the
export list and the implementation, since they are much more closely
related to each other than to this new procedure.

And as discussed in another message, let's rename the procedure and
replace the hard-coded 2 with an argument.

     Thanks,
       Mark

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19 14:43       ` Mark H Weaver
@ 2014-10-19 17:45         ` Ludovic Courtès
  0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2014-10-19 17:45 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel

Mark H Weaver <mhw@netris.org> skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> John Darrington <john@darrington.wattle.id.au> skribis:
>>
>>> How about something like (string-take-fields "1.22.3.04.5" 3) which would return "1.22.3"
>>
>> Agreed.  What ‘version-prefix’, with the optional argument defaulting
>> to 2?
>
> I also like 'version-prefix', although I'd favor making it a required
> argument.  The improved code clarity is well worth two extra characters.

OK, let’s do that.

Ian: could you post an updated patch?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19  7:40   ` John Darrington
  2014-10-19  9:39     ` Ludovic Courtès
@ 2014-10-19 18:15     ` Ian Denhardt
  2014-10-19 20:24       ` Ludovic Courtès
  1 sibling, 1 reply; 11+ messages in thread
From: Ian Denhardt @ 2014-10-19 18:15 UTC (permalink / raw)
  To: John Darrington; +Cc: guix-devel

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

Quoting John Darrington (2014-10-19 03:40:36)
> 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?

I started off with it as a parameter, then noticed the fact that it
was always the first two parts, so got rid of it. The thing is, this
*isn't* a coincidence. It's *very* common to have the first two parts
of the version encode compatibility information - when the second
number (minor) changes, the API has changed, but not in a way that
will break existing changes (though new programs may not work with
older versions). When the first number (major) changes, The API has
changed in a way that may break old programs. It's also very common
to have a looser version of this -- major indicates Big Changes, minor
is a feature release, and anything smaller than that is just bug fixes.

I'd be okay with adding the number of fields as an optional argument,
but I think given its typical use it should stay optional. I'd also like
the name to continue to reflect the semantics above; that seems to be
the common case. 

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

I'm with Ludo and Mark on this one -- I think it's overkill.

How about this: separate it out into to functions: version-prefix, which
is the same as what I have now, but takes a (mandatory) argument
specifying the number of fields, and feature-version, which is defined
like:

    (define (feature-version version) (version-prefix version 2))

..with an appropriate docstring explaining the use case. Thoughts?

Also: as Mark requested, I will reorder the functions to keep
version-compare and version>? together.

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABAgAGBQJUQ/+rAAoJEPZUuMfUyjy4e7sQAOQ4JN5ABZfj/xMplzx8VzF2
pOBkPv+TcA/y2idRiTO1hUGzGRTOE8oKKzLfu+urgbt/MxpNQ1YP238dUIt6+yZa
cQ4+ck3+gswEoyRc1M4USnELjXENx3y9r2yWzxdFqGW4YGxu22HFYf6frIj+3zfT
FiwCWGCgQcMvemxhGj2eBzYdBl56gW5mx5voZfWqcM/DQ6AwQHzfmifw95VRA91n
aHydN6zRyfNpj4COq0pcIsEud+uFUByINc0yagcSnz6DT228DNvR56TgPSfn9Rz/
J38pul6N11ul4iQFAE7M5Djo4kMCpT/33sEreeMOjw0uqr8eaM+3PPqgHGu8vFo0
S3Wd0ePGDznzlwyd72CLJFM0PIfn5Lv3rqo7at3JJA/XK52WfBYg2ajN20fGxmfo
tNkvXJE9RwWYPZvdG388sWo+cMLGsgRJCKDRFzI7sl6vgUv8qHWPTJ3PKVhdr3DT
a+bOLtijcdgu4rmRZfnMgzkhkJ1GWZiJCkAcpo1nNheKGCctYFzCW9igozlu5F3K
qteTSAJXf2nZat7h/TEzzxaAmvvKA9WLvGU6vZyomqzEiA9EimekLYRk663GLC1Z
6lMNyGs/PQl0I3+pdCw3qYfW0SklwFxVBoZ6CyGBnDWvQiAEISUHF1zWEPXTsa62
gZXS6moVHjabfKEDJ+ed
=V7T/
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19 18:15     ` Ian Denhardt
@ 2014-10-19 20:24       ` Ludovic Courtès
  2014-10-19 21:12         ` Ian Denhardt
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2014-10-19 20:24 UTC (permalink / raw)
  To: Ian Denhardt; +Cc: guix-devel

Ian Denhardt <ian@zenhack.net> skribis:

> How about this: separate it out into to functions: version-prefix, which
> is the same as what I have now, but takes a (mandatory) argument
> specifying the number of fields, and feature-version, which is defined
> like:
>
>     (define (feature-version version) (version-prefix version 2))
>
> ..with an appropriate docstring explaining the use case. Thoughts?

Sounds good to me, although I’d rather call ‘feature-version’, say,
‘version-major+minor’, on the grounds that the semantics of version
numbers are specific to each project.  Mark?

(Please forgive the extra bikeshedding.  ;-))

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] Factor out a common pattern into a procedure.
  2014-10-19 20:24       ` Ludovic Courtès
@ 2014-10-19 21:12         ` Ian Denhardt
  0 siblings, 0 replies; 11+ messages in thread
From: Ian Denhardt @ 2014-10-19 21:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

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

Quoting Ludovic Courtès (2014-10-19 16:24:17)
> Ian Denhardt <ian@zenhack.net> skribis:
> 
> > How about this: separate it out into to functions: version-prefix, which
> > is the same as what I have now, but takes a (mandatory) argument
> > specifying the number of fields, and feature-version, which is defined
> > like:
> >
> >     (define (feature-version version) (version-prefix version 2))
> >
> > ..with an appropriate docstring explaining the use case. Thoughts?
> 
> Sounds good to me, although I’d rather call ‘feature-version’, say,
> ‘version-major+minor’, on the grounds that the semantics of version
> numbers are specific to each project.  Mark?

Sounds good to me; I'll update the patch soon.

-Ian

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIbBAABAgAGBQJURCkxAAoJEPZUuMfUyjy4LOQP9RGXlXn9Mb7QwKq7mH6qRvXG
FnKjomDzYsEMcOWv4URWui0BD78M9rwo9rnPg+EDiDjCffgd4Wgl+3zq0+u4VLUF
GSLyj2KcjJSMQBLPV2/pKep/GrpkeYYvUi2estbdLda/MvIXEIARXk7MCAcrhucb
fw+GiP0YWOqX5mod2vMrxPyY/nG+KP9OTbdZp7lsX59yNNrDljrmvsM56ODlOFfe
CcA3eHhN2lZGLWHvKbzANcGiiC0a60XZjnabZGAl1Ms5cTNdXvjVKcYttNHaN35r
YfBP/cDRJdiJoSIIIAThQkG/gQzNSHctwCNck8eXBcG0XxglLy+WlOu8NUrIqkRn
kWw0AlelSFfwseiy3raseITq3X5HLnfnPI+ZRSSlFfwbdiCoCca66hljhp6h6LVo
uhGO97QweavQ2P5A/+s21QMaNYT6d2fXkaKnLhelvXJrmJ71kAblcZgJWRGcebaR
SvY9DADRwnqMtLokqzXDvOijpf6TZq0JryzIYkUTTz7A2npYbi1SYgGL8GyZFYyz
6t5oaVTaFULnapQ9/4DhDcex8t5El6KYsrXdI5VKV+E+oreBE7V9X310HMPPytrp
iug1tXShqnPx6arz2+qNyvJWS+9MwVYQATLlXwpH9xL+HvC0NX+tUoUvWEWJmYHQ
JQJ2P419GWbf86iB1Bo=
=lCnP
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-10-19 21:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-19  2:18 [PATCH 0/1] *** SUBJECT HERE *** Ian Denhardt
2014-10-19  2:03 ` [PATCH 1/1] Factor out a common pattern into a procedure Ian Denhardt
2014-10-19  7:40   ` John Darrington
2014-10-19  9:39     ` Ludovic Courtès
2014-10-19 14:43       ` Mark H Weaver
2014-10-19 17:45         ` Ludovic Courtès
2014-10-19 18:15     ` Ian Denhardt
2014-10-19 20:24       ` Ludovic Courtès
2014-10-19 21:12         ` Ian Denhardt
2014-10-19 14:57   ` Mark H Weaver
2014-10-19  2:29 ` [PATCH 0/1] *** SUBJECT HERE *** Ian Denhardt

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).