[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: RFC: A new helper class
From:       Jaros³aw_Staniek <js () iidea ! pl>
Date:       2004-10-04 18:37:44
Message-ID: 200410042037.44844.js () iidea ! pl
[Download RAW message or body]

Olivier Goffart wrote:

> Le Lundi 4 Octobre 2004 16:14, Jaros³aw Staniek a écrit :
>> Allan Sandfeld Jensen wrote:
>> > Maybe I am old-fashioned, but I prefer the traditional C-way of
>> > representing this:
>> > int ret;
>> > ret>0 -> true
>> > ret==0 -> false
>> > ret<0 -> error/exception
>> >
>> > It provides more than one abnormal termination type, which you often
>> > need, and this scheme can also handle any function with positive
>> > integer return-types.
>>
>> Depends whether we want to read documentation or have self-documented
>> code. To montion C-style, there is also other standard behaviour where 0
>> means true.
>>
>> On the other hand, I am (ans we all) also still _using_ ints for wider
>> cases. But there was so many cases for functions using 3-state logic that
>> I've found the class usable.
> 
> Why not a simple enum ?
> In most case, an enum is more redable then a bool if you give meaningfull
> names to the enum members.

As Richard Dale mentioned, booleans are booleans. Unlike simple enum, tristate 
inherits everything from bool type, I mean: operators !, =, and implicity 
casts to (bool).

Operator ~ is consistent addition, in my opinion. Thus even "! ~" working as 
"not cancelled" :)

With tristate class you can forget about it's additional meaning and just 
treat it as a bool.

-- 
regards / pozdrawiam,
  Jaroslaw Staniek / OpenOffice Polska
  Kexi Project: http://www.kexi-project.org, http://koffice.kde.org/kexi
  QT-KDE Wrapper Project: http://iidea.pl/~js/qkw

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic