Gentoo Archives: gentoo-dev

From: Maciej Mrozowski <reavertm@××××××.fm>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] EAPI 3 and "nonfatal die"
Date: Fri, 21 Aug 2009 23:02:01
Message-Id: 200908220101.49154.reavertm@poczta.fm
In Reply to: Re: [gentoo-dev] EAPI 3 and "nonfatal die" by Ciaran McCreesh
1 On Friday 21 of August 2009 23:12:23 Ciaran McCreesh wrote:
2 > On Fri, 21 Aug 2009 23:09:33 +0200
3
4 > Maciej Mrozowski <reavertm@××××××.fm> wrote:
5 > > I suggest #5 - drop the idea of 'nonfatal'.
6
7 > Then how do you plan to handle all the standard utilities that die on
8 > failure in EAPI 3?
9
10 >>> #1 make die respect nonfatal
11 The most obvious. About consequences - when you override behaviour of "die-on-
12 failure" function (that has been marked as fatal for reason) you're supposed
13 to know what you're doing, so all codepaths should be checked in that case,
14 otherwise one should be really ready to grab the pieces in such case.
15
16 >>> #2 make die always die
17 In such case nonfatal is useless as it's supposed to surpass "die-on-failure"
18 EAPI3 functions, am I right?
19 Correct me if I'm wrong, bug there are just two ways to mark function
20 invocation as 'failed':
21 - return nonzero value - soft way
22 - abort further execution of script, so call die function - hard way
23
24 In such case nonfatal works against its purpose (it cannot interfere in
25 arbitrary function's flow control, and return value only affects this, so the
26 only mean for it is to interfere in general-purpose-die-function).
27 This could be fixed by introducing 'even-more-fatal' way of aborting script
28 execution, like function 'really-die-seriously-this-time' that ignores
29 'nonfatal' :P (which leads us to #3 and #4).
30
31 >>> #3 add a new die variant that respects nonfatal
32 Seems the most reasonable to me, but should be introduced with caution (if at
33 all). It's very old question how to approach flow control: whether to:
34 - maintain in using 'do_it_now_think_later' approach (exceptions' handling,
35 nonfatal)
36 - 'do_it_now_think_now' (checking return values)
37 Ideally would be to have just one.
38 And if the goal is to implement exception-handling-like (actually catching and
39 ignoring) approach in flow control for EAPI3 instead of relying on return
40 value (|| die) with runtime errors throwing (current 'die'), one would need
41 not just one or two "die functions", but maybe whole family, with different
42 fatality levels (for example controlled by environment variable, so that one
43 could ignore those with level > 0 or could be more strict and only ignore
44 those with level > 2, when 0 would be the most fatal, 1 less-lethal and so
45 on).
46
47 >>> #4 make regular die respect nonfatal, and add a new variant that doesn't)
48 we should go with?
49 All existing 'die' invocations now are supposed to be fatal (according to
50 definition in devmanual), so making them maybe-fatal in EAPI3 is wrong imho.
51
52 General problem is defining what's really fatal and what's not - and I can
53 assure that someone in a future will find some use case for preventing
54 aborting of execution of some fatal function that failed.
55
56 That being said I don't like refraining from "return value approach" towards
57 "exception handling approach" (and I'm ebuild/eclass developer and I don't see
58 adding || die very disturbing) that has been proposed for EAPI3 in die-on-
59 failure utility functions, and thus I don't like nonfatal (which is of course
60 needed for them).
61
62 --
63 regards
64 MM

Attachments

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

Replies

Subject Author
Re: [gentoo-dev] EAPI 3 and "nonfatal die" Ciaran McCreesh <ciaran.mccreesh@××××××××××.com>