Gentoo Archives: gentoo-dev

From: Kent Fredric <kentnl@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] eapi7-ver.eclass: 'Early adopter' version of EAPI 7 version manip
Date: Sat, 09 Sep 2017 15:06:54
Message-Id: 20170910030556.666c392b@katipo2.lan
In Reply to: [gentoo-dev] [PATCH] eapi7-ver.eclass: 'Early adopter' version of EAPI 7 version manip by "Michał Górny"
1 On Fri, 8 Sep 2017 13:19:23 +0200
2 Michał Górny <mgorny@g.o> wrote:
3
4 > a. getting wider review and some real-life testing before
5 > the specification is set in stone, and
6
7 Any thoughts on a function that would represent a dotted-decimal style version
8 as a floating point string?
9
10 eg:
11
12 ver_float 0.1.0 -> 0.001
13 ver_float 0.10.0 -> 0.010
14 ver_float 0.100.0 -> 0.100
15
16 That's of course *the most* generic example I can offer, but seeing
17 this sort of transformation is commonly needed in the world of perl, I
18 thought maybe now is a good time to mention something.
19
20 Sadly, its just the sort of idea that if done wrong, would be no use.
21
22 For instance, sometimes you want:
23
24 ver_float 0.1.0 -> 0.0010
25
26 Or
27
28 ver_float 0.1.1 -> 0.001001
29
30 The two key things here is to know:
31
32 1. How many digits each position represents
33 2. The maximum number of digits to represent
34
35 So, some ideas in that regard are:
36
37 ver_float ${INPUT} ${PRECISION}
38
39 Where the values per position are fixed, so:
40
41 ver_float 0.1 3 -> 0.001
42 ver_float 0.1 2 -> INVALD # fidelity loss by truncation
43 ver_float 0.10 2 -> 0.01 # permitted because there's no fidelity loss by truncation
44 ver_float 0.100 1 -> 0.1 # permitted because there's no fidelity loss by truncation
45 ver_float 0.100 2 -> 0.10
46 ver_float 0.100 3 -> 0.100
47 ver_float 0.101 1 -> INVALID # fidelity loss by truncation
48
49 ver_float 0.1 5 -> 0.00100
50 ver_float 0.1.1 5 -> INVALID, need 6 digits to represent 0.1.1
51
52 ver_float 0.1.1 6 -> 0.001001
53
54
55 Or say,
56
57 ver_float ${INPUT} ${PATTERN}
58
59 Where "pattern" is a string like 3-3-3 indicating how to map digits to numbers
60
61 ver_float 0.1 3 -> 0.001
62 ver_float 0.1 2 -> 0.01
63 ver_float 0.1 1 -> 0.1
64 ver_float 0.1.1 3 -> # INVALID, no map for '.1'
65 ver_float 0.1.1 3-3 -> 0.001001
66 ver_float 0.1.10 3-3 -> 0.001010
67 ver_float 0.1.10 2-2 -> 0.0110
68 ver_float 0.10.10 2-2 -> 0.1010
69 ver_float 0.100.10 2-2 -> # INVALID, can't map "100" into 2 characters
70
71 Though I suspect you'd want both features ...
72
73 ver_float ${INPUT} ${PATTERN} ${TRUNCATION_LENGTH}
74
75 Because we do need packages where
76
77 0.123.10 means 0.1231
78
79 Either way, much of this is probably a time wasting bad idea.
80
81 But I thought I'd just
82
83 ( •_•)
84
85 ( •_•)>⌐■-■
86
87 (⌐■_■)
88
89 Float it by you.

Replies