Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] unprivileged mode: generate PORTAGE_DEPCACHEDIR
Date: Sat, 15 Nov 2014 05:19:45
Message-Id: 5466E26D.6090802@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] unprivileged mode: generate PORTAGE_DEPCACHEDIR by Alexander Berntsen
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

Replies