You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by se...@wso2.com on 2007/10/28 13:24:09 UTC

Need of a new coding convention

As you see, axis2_bool_t, has two values, AXIS2_TRUE and AXIS2_FALSE that
corresponds to true and false respectively.
Now when such a type is compared in an 'if' or a 'while' as in,
if (..statement..) or while (..statement..) there are two mechanisms used.

That is,
lets assume myVar = AXIS2_TRUE;

Now, we have used,
1. if (myVar) { }
2. if (AXIS2_TRUE == myVar) { }

Therefore, it is kind of confusing at times.

As, AXIS2_TRUE is being defined as 1, and AXIS2_FALSE is being defined as
0, things would work alright (refer axutil_utils_defines.h).

But, however, it is better to stick to option 2, as  axis2_bool_t is
derived from int, and thus can have more than 2 values in theory (Ex:- if
someone sets myVar = 3). If we opt to use option 1, it could potentially
lead to an erroneous state recognized as true, which is apparently not
what we expect.

I believe this issue needs some attention.

Senaka.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: Need of a new coding convention

Posted by se...@wso2.com.
Hi all,
I'm sorry for mailing the wrong list.
The mail to which I'm replying is intended for axis2 developers.
Sorry for any inconvenience caused.

Senaka.

> As you see, axis2_bool_t, has two values, AXIS2_TRUE and AXIS2_FALSE that
> corresponds to true and false respectively.
> Now when such a type is compared in an 'if' or a 'while' as in,
> if (..statement..) or while (..statement..) there are two mechanisms used.
>
> That is,
> lets assume myVar = AXIS2_TRUE;
>
> Now, we have used,
> 1. if (myVar) { }
> 2. if (AXIS2_TRUE == myVar) { }
>
> Therefore, it is kind of confusing at times.
>
> As, AXIS2_TRUE is being defined as 1, and AXIS2_FALSE is being defined as
> 0, things would work alright (refer axutil_utils_defines.h).
>
> But, however, it is better to stick to option 2, as  axis2_bool_t is
> derived from int, and thus can have more than 2 values in theory (Ex:- if
> someone sets myVar = 3). If we opt to use option 1, it could potentially
> lead to an erroneous state recognized as true, which is apparently not
> what we expect.
>
> I believe this issue needs some attention.
>
> Senaka.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org