lilypond-devel
[Top][All Lists]
Advanced

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

Re: Add lilypond version predicates/operators (issue 317270043 by addres


From: thomasmorley65
Subject: Re: Add lilypond version predicates/operators (issue 317270043 by address@hidden)
Date: Tue, 14 Feb 2017 13:03:19 -0800

To throw in my own 2cts.

Why not compare strings, looks more straight forward to me.

(define (calculate-version-harm ref-version)
  (cond ((string? ref-version) ref-version)
        ((number-list? ref-version)
         (string-concatenate (list-join (map number->string ref-version)
".")))
        (else (ly:error "whatever-massage"))))

(define (version-compare? op v1 v2)
"Compare two versions @var{v1} and @var{v2} with the operator @var{op}.
  The operator would typically be
  string=?, string<?, string<=? , string>? , string>=? , etc."
 (op (calculate-version-harm v1) (calculate-version-harm v2)))

;; Examples
(write (version-compare? string=? (lilypond-version) (ly:version)))
(write (version-compare? string>? "2.19.57" (ly:version)))
(write (version-compare? string<=? "2.19.57" (lilypond-version)))

The issue I can imagine: probably more expensive, especially with
guilev2

In a ly-file:

$ time lilydevel atest-48.ly
GNU LilyPond 2.19.52
Processing `atest-48.ly'
Parsing...#t#t#f
Success: compilation successfully completed

real    0m1.279s
user    0m1.148s
sys     0m0.128s

Using a build from (not so) recent master, with guile-2.1.6:

$ time lilypond-git atest-48.ly
GNU LilyPond 2.19.55
Import (ice-9 threads) to have access to `call-with-new-thread'.
Import (ice-9 threads) to have access to `current-thread'.
Processing `atest-48.ly'
Parsing...#t#t#f
Success: compilation successfully completed

real    0m5.145s
user    0m5.620s
sys     0m0.120s


Cheers,
  Harm

https://codereview.appspot.com/317270043/



reply via email to

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