Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [RFC] Restricting allowed nesting of REQUIRED_USE
Date: Mon, 12 Jun 2017 18:52:13
Message-Id: 1497293517.1575.1.camel@gentoo.org
In Reply to: [gentoo-dev] [RFC] Restricting allowed nesting of REQUIRED_USE by "Michał Górny"
1 On sob, 2017-06-10 at 00:30 +0200, Michał Górny wrote:
2 > Below I have listed the clauses I'd like to ban in a few logical groups,
3 > along with explanations and examples.
4 >
5 > [...]
6
7 Actually, after some thinking, here's one more:
8
9 4. All-of operator inside ||
10 ----------------------------
11
12 While this is not as bad as the others, it probably makes sense to ban
13 it to preserve symmetry between operators. It has very little real use,
14 killing it simplifies all algorithms even more. Since it was the last
15 valid use of all-of operator, this means we can ban it altogether
16 in REQUIRED_USE.
17
18 The only real use in ::gentoo right now is:
19
20 || ( deprecated ( gtk3 introspection ) ) )
21
22 which is equivalent to:
23
24 !gtk3? ( deprecated ) !introspection? ( deprecated )
25
26 While the former is a little shorter and might be considered somewhat
27 readable, I don't think it's worth to keep the extra complexity for
28 a single package. Especially considering that the package is not even
29 using it correctly since -- judging by the code -- it should actually
30 have:
31
32 python? ( gtk3? ( introspection ) )
33
34 which would render the above clause irrelevant.
35
36 The two remaining uses of all-of in ::gentoo are obvious mistakes --
37 accidental extra parentheses.
38
39 > Resulting AST
40 > =============
41 >
42 > If all three classes I've mentioned were banned, the AST would look
43 > like:
44 >
45 > REQUIRED_USE := [<top-expr>...]
46 >
47 > top-expr := <flag> | <use-cond> | <any-of> | <most-one-of> | <exactly-one-of>
48 >
49 > flag := ['!']<flag-name>
50 >
51 > use-cond := ['!']<flag-name>'? (' <top-expr>... ')'
52 >
53 > any-of := '|| (' <any-of-expr>... ')'
54
55 Now:
56
57 any-of := '|| (' <flag>... ')'
58
59 > any-of-expr := <flag> | <all-of>
60
61 Scratch that.
62
63 > most-one-of := '??' ( <flag>... )
64 >
65 > exactly-one-of := '^^' ( <flag>... )
66 >
67 > all-of := '(' <flag>... ')'
68 >
69 >
70 > Note that only USE conditionals are deeply nested now. Of all other
71 > groups, || can contain pure flags and/or all-of blocks (which contain
72 > only pure flags), and ?? and ^^ contain pure flags only.
73 >
74
75 Now even better. ||, ?? and ^^ all are pure, flat groups of USE flags.
76
77
78 --
79 Best regards,
80 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature