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: dak
Subject: Re: Add lilypond version predicates/operators (issue 317270043 by address@hidden)
Date: Tue, 14 Feb 2017 08:29:50 -0800

On 2017/02/14 15:51:13, dak wrote:
On 2017/02/14 15:49:26, dak wrote:
> On 2017/02/14 15:46:20, git wrote:
> > On 2017/02/14 15:37:35, pwm wrote:
> > > On 2017/02/14 15:15:07, git wrote:
> > > > I like this more because it's more of a typical procedure
invocation.
> > > > I think I'll create a new patch with this and a simplified
> calculate-version
> > > > (that doesn't accept string lists)
> > >
> > > Well, having the procedure as the first argument might be more
scheme-ish?
> > >
> > > Maybe best would be to have a "version-compare" function that
compares two
> > > version lists using a procedure.  Then define "ly:version?" so
it calls
> > > "version-compare" with the current LilyPond version (to handle
the primary
> use
> > > case).  The "version-compare" function could be David's looping
function,
> but
> > > modified so that it took two version lists and a procedure as
arguments.
> >
> > This is what I'm currently working on.
> > However, I found an issue in David's suggestion, namely the
> > (op 0 0) ;; return #t iff op includes equality
> > line.
> > This makes the function return #t when comparing with = and one
list
shortened
> > Try e.g. (ly:version? = 2 16)
> > This returns #t because in the third iteration when the reference
version
has
> > run out of elements it compares 0 to 0.
>
> Have you actually tried it?  If your major version is not actually
2.16, you
> will not even _get_ into a third iteration.

Ok, I take that back.  I admit that the tie-breaker does not work with
strict
equality.  I'll have to think about it.

How about:

#(define (ly:version? op . rest)
   (define eqlop (op 0 0))
   (let loop ((ver (ly:version)) (rest rest))
     (if (or (null? ver) (null? rest))
         eqlop
         (let* ((a (car ver)) (b (car rest))
                (axb (op a b)) (bxa (op b a)))
           (if (eq? axb bxa eqlop)
               (loop (cdr ver) (cdr rest))
               axb)))))


#(format #t "> 2.19 : ~S, >= 2.19 : ~S\n= 2.16 : ~S, = 2.19 : ~S\n"
         (ly:version? > 2 19)
         (ly:version? >= 2 19)
         (ly:version? = 2 16)
         (ly:version? = 2 19))


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



reply via email to

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