1 |
On 11/11/2014 01:14 AM, Alexander Berntsen wrote: |
2 |
> On 11/11/14 01:17, Zac Medico wrote: |
3 |
>> We could certainly express it in a way that doesn't involve any |
4 |
>> mutating loop control variables, but ultimately that's going to |
5 |
>> lead to more lines of code, and it will leave imperative |
6 |
>> programmers wondering why we didn't choose a simpler and more |
7 |
>> succinct approach. |
8 |
> |
9 |
>> For example, we could create an class for iterating over the paths |
10 |
>> from a given path down to the root directory. Then we could create |
11 |
>> a function which selects the first element from that iterator that |
12 |
>> exists. Once the class and function are implemented, their usage |
13 |
>> would be very succinct: |
14 |
> |
15 |
>> first_parent = first_existing(iter_parents(path)) |
16 |
> I would greatly prefer this. But I suppose I'm in a minority. v2 of |
17 |
> the patch is fine by me. |
18 |
|
19 |
Thanks. I eliminated one more backslash, and pushed it. |
20 |
|
21 |
Now I'm thinking about splitting out a first_existing function so that I |
22 |
can use it in portage.data._unprivileged_mode(), to determine if the |
23 |
unprivileged root can be created. Maybe I'll do it with the iterator |
24 |
approach that we've discussed, and we'll see what the consensus is. |
25 |
-- |
26 |
Thanks, |
27 |
Zac |