Gentoo Archives: gentoo-dev

From: Kent Fredric <kentfredric@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] rfc: calling all eclass phase functions by default
Date: Sat, 16 Aug 2014 22:32:22
Message-Id: CAATnKFB4E3UrQgeRvi5h0N0tXkhUT8mR3Yk56t2hiy9afojqCQ@mail.gmail.com
In Reply to: [gentoo-dev] rfc: calling all eclass phase functions by default by William Hubbs
1 On 17 August 2014 09:54, William Hubbs <williamh@g.o> wrote:
2
3 > I strongly oppose this change, because I feel it will make our
4 > entire tree very unpredictable at best. I realize this might eliminate
5 > boilerplating from our tree. Weighing that against the possible
6 > ramifications in this big of a change in automagic behaviour, I think
7 > the cost is much higher than the gain.
8 >
9 >
10
11 I agree on that part, for what its worth.
12
13 The current system we have in place is an analogue of "role based" or
14 "trait based" inheritance, where you have very straight forward composition
15 behavior with regards to the final ebuild.
16
17 One of the parent classes "wins", and if you don't like this, you have to
18 adapt it manually.
19
20 This in practice usually proves more useful than diamond style multiple
21 inheritance, that while seeming like a nice idea in concept, in practice
22 proves more complicated than its worth.
23
24 The only downside I see is we don't have a clear straight forward collision
25 strategy, which is essential for most role based systems:
26
27 For instance,
28
29 dog.eclass : function bark
30 tree.eclass: function bark
31
32 Proves not to be resolvable automatically in a sensible way.
33
34 Collison systems I've seen usually do one of two things:
35
36 - In the event of a collision, demand the consumer resolve the problem by
37 redefining the function the collision occurs on in terms of its composite
38 parts. ( which is basically what we already do )
39 - Declare syntax to "exclude" a potential collision from either composite
40 part.
41
42 Our only real difference at present is unlike these systems, we assume we
43 can simply guess which one wins and just choose it automatically, where
44 collision systems tend to force you to deal with the situation if any
45 collision occurs.
46
47
48
49 > I am also not very comfortable with our current state, because it has
50 > a lot of uncertainty in terms of how the eclass phase functions are
51 > called.
52 >
53 > My counter proposal to this is that we stop calling eclass phase
54 > functions automatically, and to minimize the amount of boilerplating
55 > we would have to do, we use a variable, such as ECLASS_PHASES which
56 > would be defined at the ebuild level and contain a list of the eclass
57 > phase functions we want to run automatically.
58 >
59 > Going back to my previous example, say your ebuild does the following:
60 >
61 > -- code begins here --
62 >
63 > inherit foo bar
64 >
65 > # Foo and bar both have src_unpack and src_install functions.
66 > # we want foo's src_unpack and bar's src_install:
67 >
68 > ECLASS_PHASES="foo_src_unpack
69 > bar_src_install"
70 >
71 > -- code ends here ---
72 >
73 > If ECLASS_PHASES is undefined, I think the default should be to not run
74 > the eclass phase functions.
75 >
76 > Yes, this means there is some boilerplating. However, there are some
77 > strong advantages:
78 >
79 > - this is no longer dependent on order of inheritance.
80 > - The ebuild author knows exactly which eclass phase functions will
81 > be run.
82 >
83 >
84 This proposal, seems reasonable, given my comments. I anticipate however
85 its biggest downside would be
86 the requirement to state *all* the functions you want, which would lead to
87 maintenance headaches
88 due to people forgetting to declare they wanted some function or other.
89
90 So if you could sculpt it to be broader by default and have less scope for
91 developer error, that'd be an improvement.
92
93 --- code start --
94 ECLASS_EXCLUDE="foo_src_unpack bar_src_unpack"
95 inherit foo bar baz
96
97
98 --- code end ---
99
100 here, src_unpack would be baz_src_unpack *regardless* of composition order
101 because "foo" and "bar" were barred from being used, and baz took
102 precedence as a result.
103
104 If baz provides no src_unpack, then the ebuild in question is simply left
105 without one.
106
107 You'll still need to declare src_unpack explicitly if you need use
108 conditional behaviour, however.
109 --
110 Kent
111
112 *KENTNL* - https://metacpan.org/author/KENTNL

Replies