RFC: A new helper class

Olivier Goffart ogoffart at tiscalinet.be
Mon Oct 4 19:02:08 BST 2004


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041004/46173e1e/attachment.sig>


More information about the kde-core-devel mailing list