1 |
On Mon, 29 May 2017 23:23:55 +0200 |
2 |
Michał Górny <mgorny@g.o> wrote: |
3 |
|
4 |
> On pon, 2017-05-29 at 20:00 +0200, Alexis Ballier wrote: |
5 |
> > On Mon, 29 May 2017 17:33:13 +0200 |
6 |
> > Michał Górny <mgorny@g.o> wrote: |
7 |
[...] |
8 |
> > > It can also be used with multi-flag ??, ^^ and || constraints, |
9 |
> > > i.e.: |
10 |
> > > |
11 |
> > > - ?? means that at most one of the flags can be enabled. If user |
12 |
> > > configuration causes more than one of the flags to be enabled, |
13 |
> > > additional flags are implicitly disabled (masked) to satisfy |
14 |
> > > the constraint. |
15 |
> > > |
16 |
> > > - || means that at least one of the flags must be enabled. If user |
17 |
> > > configuration causes none of the flags to be enabled, one of them |
18 |
> > > is enabled implicitly (forced). |
19 |
> > > |
20 |
> > > - ^^ means that exactly one of the flags must be enabled. The |
21 |
> > > behavior is a combination of both above constraints. |
22 |
> > > |
23 |
> > > The automated solving of USE constraints would require the |
24 |
> > > developers to consider the implicit effect of the constraints |
25 |
> > > they are writing. |
26 |
> > |
27 |
> > |
28 |
> > Can you provide an efficient algorithm for the above syntax? |
29 |
> > That is, given a set of +/- useflags forced by user, output the set |
30 |
> > of effective useflags (or a rant if it is inconsistent). |
31 |
> |
32 |
> I'd rather leave that to people who are good with algorithms. I find |
33 |
> the whole thing scary but I don't really see a sane alternative here. |
34 |
|
35 |
Well, Ciaran is a bit extreme with his implementation thing, but |
36 |
he's right in the sense that here you're really repeating the same |
37 |
mistakes that you're trying to fix. REQUIRED_USE was invented the same |
38 |
way: Let's add some nice syntax to express dependency between useflags. |
39 |
Ship it. Oh crap, this requires to solve SAT. Well, nothing good can be |
40 |
done here, let's spit out to the user to chose for herself. |
41 |
With your proposal, it seems to me you're simply postponing the problem |
42 |
but not fixing it: Instead of spiting that one has to enable some |
43 |
useflags, you'd spit that one has to specify how to solve the |
44 |
constraint by expressing some preference. In the end, this'll add |
45 |
another layer of complexity in both PM and the user configuration but |
46 |
would not solve the root of the problem which is that no-one knows how |
47 |
to automatically find a solution to those constraints and PM can't take |
48 |
any action without user input. |
49 |
|
50 |
You can't get away with "There is a solution but I'll leave that to |
51 |
people who are good with algorithms": That is roughly the definition of |
52 |
NP. If the person writing a proposal for a new feature (which is thus |
53 |
supposedly the one person that has thoroughly thought the problem) can't |
54 |
at least roughly draft how to implement it, that doesn't give much faith |
55 |
in that it can be done properly. It certainly does not mean said person |
56 |
is not good with algorithms but rather that the problem is very likely |
57 |
to be a hard one. Not hard as in you need a Ph.D. in algorithms to |
58 |
solve it but the kind of hardness almost every cryptographic algorithm |
59 |
used today, and in the foreseeable future, relies on. |
60 |
|
61 |
> Worst case, we have to figure out some arbitrary limitations to keep |
62 |
> things sane. |
63 |
|
64 |
The main point of my reply was (and still is) to find such limitations. |
65 |
It is not as arbitrary as you may think and requires to be properly |
66 |
understood so that we have to sacrifice the least expressivity power. A |
67 |
good way to understand what a proper limitation would be is to try to |
68 |
solve the problem. |
69 |
|
70 |
> > Maybe I'm mistaken, but I doubt it is possible with n-ary |
71 |
> > constraints. |
72 |
> > |
73 |
> > Now the extra question: Do those n-ary operators have any |
74 |
> > advantage ? |
75 |
> |
76 |
> Yes, they do. They improve readability, compared to cascades of plain |
77 |
> constraints. I'm pretty sure users will be happier to see 'you need to |
78 |
> select one of foo, bar, baz' than 'if foo is disabled, then ...' |
79 |
|
80 |
If the point is to automatically propose a solution, then who cares |
81 |
about readability? Users won't even see that message. |
82 |
|
83 |
Note that there are plenty of ways to add determinism in your proposal, |
84 |
but it *has* to be specified otherwise PM can't rely on it. For |
85 |
instance, you can say that in an unsatisfied || block then the |
86 |
left-most useflag is automatically enabled. || then becomes some |
87 |
syntactic sugar around unary operators: || ( a ... ) becomes equivalent |
88 |
to '!...? ( a )'. You can do the same for other operators. |
89 |
|
90 |
|
91 |
Sidenote: I just realized '|| ( a b c )' with left-most preference might |
92 |
be better since we are not dealing with binary variables but ternary |
93 |
ones (user disabled, user enabled, unspecified). 'USE="" || ( a b c )' |
94 |
should evaluate to 'a', 'USE="-a" || ( a b c )' should evaluate to 'b'. |
95 |
I don't see how to rewrite that with pure implications. |
96 |
|
97 |
> > The point is to express some preference, below you suggest to leave |
98 |
> > that to the user, but what about leaving that to the ebuild |
99 |
> > developer? |
100 |
> |
101 |
> Well, I don't find that a killer feature but I don't see a reason to |
102 |
> take it away either. Either way we have some risks, especially when |
103 |
> USE dependencies and blockers are involved. In both scenarios, I find |
104 |
> it less risky to let user control the order than to rely on all |
105 |
> developers respecting the same preference order. Not saying the |
106 |
> latter wouldn't hurt anyway but the users would at least have an easy |
107 |
> way out. |
108 |
|
109 |
They already have an easy way out if you strip that part out of your |
110 |
proposal: emerge will show some automatically enabled useflags; users |
111 |
will notice and will fill package.use to disable the automatically |
112 |
enabled useflag if they don't want it. |
113 |
|
114 |
> > That way, e.g., || can be rewritten as implications: '|| ( a b c )' |
115 |
> > becomes '!b? !c? a' meaning if none is enabled then a is |
116 |
> > automatically enabled. |
117 |
> |
118 |
> Unless you are planning to cache the rewritten forms, I don't see |
119 |
> a problem, really. You just reorder the flags according to the |
120 |
> apparent preference before rewriting. |
121 |
|
122 |
It's not a problem of rewriting or caching the result but a problem of |
123 |
having a deterministic way to auto-enable required useflags. |
124 |
|
125 |
Bests, |
126 |
|
127 |
Alexis. |