[squeak-dev] Re: 1.0 not a valid VersionNumber?

Stephen Pair stephen at pairhome.net
Wed Apr 9 17:31:13 UTC 2008


Wow, this is a blast from the past.

On Wed, Apr 9, 2008 at 12:57 PM, Andreas Raab <andreas.raab at gmx.de> wrote:

> Question: Is there an implementation dependency for that or is it simply
> that VersionNumber is being overly paranoid here? In its current incarnation
> it's basically useless for me and I'd rather have the check be for negative
> numbers only.
>

That's just a design decision I made.  I felt was would be confusing to have
version numbers "1" and "1.0" in the same lineage.  When you create a
branch, you would make "1.1" based on "1".

John Thornborrow wrote:
>
> > Wouldn't that just be "Version 1" ?
> >
>
> Simplified example. The real version number I'm interested in looks like
> "1.0.34". But it looks like VersionNumber is a no-go for me anyway as you
> can't even compare, e.g., '1.1.1' asVersion <= '1.2.3' asVersion. Does
> anyone actually use VersionNumber? I must be missing the real use cases for
> it.


I'm curious whether you'd expect this to return true or false (I'm guess
true).  The reason it refuses that compasion is that #< is meant to test
whether a given version number is an ancestor of another.  If you want the
stringish comparison behavior, you could just use string.  Or, you could
extend the class with a different comparison method to do what you want.
 The motivation for this class was to give a structured way to used dotted
number strings to encapsulate information about versions and branches.  I've
copied the class comments below.

- Stephen

---------------------
I am a version number.  My representation allows me to handle an entire tree
of versions.  Once created, an instance should not change (note:
VersionNumbers could be canonicalized like Symbols, but are not currently).


I am a magnitude so that you can see if one version preceeds another (only
if the two versions are in the same branch).
VersionNumber fromString: '1.0'.
'2.1' asVersion < '2.2.1' asVersion "true"
'2.3' asVersion < '2.2.1' asVersion "error different branches"
'2.3' asVersion inSameBranchAs: '2.2.1' asVersion "false, why the previous
one failed."
'2.1' asVersion = '2.1' asVersion "true, obviously"

To get the next version number in the same branch:

'2.3.4' asVersion next "2.3.5"

To get the next version number, starting a new branch:

'2.3.4' asVersion branchNext "2.3.4.1"

To get the common base version of any two version numbers (useful for
merging):

'2.3.8' asVersion commonBase: '2.3.4.1' asVersion "2.3.4"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080409/f0dd11a7/attachment.htm


More information about the Squeak-dev mailing list