[Tinyos-devel] Combine function for bool

Philip Levis pal at cs.stanford.edu
Wed Apr 1 13:35:41 PDT 2009


On Apr 1, 2009, at 7:14 AM, Morten Tranberg Hansen wrote:

> Hi all,
>
> Is there any specific reason for not having a combine function for  
> bool types defined in tos.h.  If not, I suggest to add:
>
> typedef uint8_t bool @combine("bcombine");
>
> bool bcombine(bool b1, bool b2) @safe() {
>   return b1 && b2;
> }
>
> Instead of just having:
>
> typedef uint8_t bool;

I don't think bool has enough information: why is it && and not ||?  
For example, if I want to know whether everything is ready by calling  
some function called isReady(), I would want &&, but if I want to know  
if everything is ready by calling some function isBusy(), I would want  
||. That is, which combine you want depends on the semantics of the  
function.

Phil


More information about the Tinyos-devel mailing list