Michael is not subscribed, forwarding...
----- Forwarded message from Michael Meeks
Hi! What is the reasoning behind using tribool? This seems to be the biggest headache for application developers so far... Stano Dňa Po 23. Júl 2007 17:25 Martin Vidner napísal:
Michael is not subscribed, forwarding...
----- Forwarded message from Michael Meeks
----- Subject: tribool ... From: Michael Meeks To: zypp-devel@opensuse.org Cc: Ricardo Cruz Organization: Novell, Inc. X-Mailer: Evolution 2.6.0 Date: Mon, 23 Jul 2007 08:55:13 +0100 Hi guys,
So - I learned something fun, interesting and new this morning (at the cost of an hour or so) - it was the joys of the tribool:
if (available_obj != NULL && !available_obj->repository().info().enabled()) {
In normal usage, by the power of sequence points, this sort of thing works nicely (and indeed, it used to work before the API re-hash I think).
Unfortunately, with a tri-bool around this becomes a mess, sequence points are no longer your friend:
return false && !(zypp::ResObject::constPtr(NULL)->repository().info().enabled()) ? 1 : 0;
SEGV's immediately - try it as a return from main() ;-) it compiles to:
return tribool.operator&& (false,
) Now the fix is 'obvious' - simply split it into 2 if's, or add a '(bool)' cast to what appears to be a bool anyway ;-) but it's pretty sickeningly non-obvious to the casual user. Also, will it survive a future maintainer's desire for cleaner code without "all these odd / redundant casts in it" ?
Urgh,
Michael.
-- michael.meeks@novell.com <><, Pseudo Engineer, itinerant idiot -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On Tue, Jul 24, Stanislav Visnovsky wrote:
Hi!
What is the reasoning behind using tribool? This seems to be the biggest headache for application developers so far...
The tribool is fine -- zypp internally. 'indeterminate' state tells that we have to compute some reasonable defaut value. This should be done internally. We'll change the API too return bool. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Dňa Ut 24. Júl 2007 14:36 Michael Andres napísal:
On Tue, Jul 24, Stanislav Visnovsky wrote:
Hi!
What is the reasoning behind using tribool? This seems to be the biggest headache for application developers so far...
The tribool is fine -- zypp internally.
'indeterminate' state tells that we have to compute some reasonable defaut value. This should be done internally.
We'll change the API too return bool.
Sounds good. Thanks for looking into this! Stano -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On Tue, Jul 24, Stanislav Visnovsky wrote:
D??a Ut 24. J??l 2007 14:36 Michael Andres nap??sal:
On Tue, Jul 24, Stanislav Visnovsky wrote:
Hi!
What is the reasoning behind using tribool? This seems to be the biggest headache for application developers so far...
The tribool is fine -- zypp internally.
'indeterminate' state tells that we have to compute some reasonable defaut value. This should be done internally.
We'll change the API too return bool.
Sounds good. Thanks for looking into this!
JFYI: With libzypp-3.13.1 (SVN revision 6301) the tribools are replaced by bool. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (3)
-
Martin Vidner
-
Michael Andres
-
Stanislav Visnovsky