From kde-core-devel Mon Oct 04 18:37:44 2004 From: =?iso-8859-2?q?Jaros=B3aw_Staniek?= Date: Mon, 04 Oct 2004 18:37:44 +0000 To: kde-core-devel Subject: Re: RFC: A new helper class Message-Id: <200410042037.44844.js () iidea ! pl> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=109691513007537 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