emacs-devel
[Top][All Lists]
Advanced

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

Re: version comparison functions


From: Kim F. Storm
Subject: Re: version comparison functions
Date: Fri, 26 Aug 2005 14:42:40 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Juanma Barranquero <address@hidden> writes:

>> version< is useful for comparing version number strings.

> So I suppose I'm just a bit surprised at the thought of adding two
> variables, seven functions and one alias just to do version
> comparison. Not even the `integer-list-*' functions are general, as
> they consider '(1) and '(1 0) to be equal, which doesn't strike me as
> a very common need. They would be better named `version-list-*', IMO.

I agree -- and I just changed their names accordingly.

I also fixed a bug that caused e.g. (version< "1" "1.0") to trap.

Finally, I changed version= from being an alias for string-equal
to using the provided version-list-= function.

Before my change:

(version< "1" "1.0")
=> nil

(version<= "1" "1.0")
=> t

(version= "1" "1.0")
=> nil


With my change, it gives the logical result.

(version= "1" "1.0")
=> t

I don't know the rationale for aliasing version= to string-equal, but
to me it was logically wrong to do so -- and if someone wants to use
string-equal, they should do so!


BTW, I agree with Juanma that this is hardly the time to add this
stuff...

..but now that it has happened, I think it makes sense for these
functions to accept an optional argument to limit the number of
version string elements to compare.  E.g.

       (version= "22.0.50" "22.0.50.37")    => nil
       (version= "22.0.50.36" "22.0.50.37") => nil

       (version= "22.0.50" "22.0.50.37" 3)    => t
       (version= "22.0.50.36" "22.0.50.37" 3) => t


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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