opEquals needs to return bool

Robert Fraser fraserofthenight at gmail.com
Fri May 16 15:20:29 PDT 2008


Janice Caron wrote:
> On 16/05/2008, BCS <ao at pathlink.com> wrote:
>>>> Bools are bytes, while ints are 4 bytes, so sometimes ints are
>>>> managed faster.
>>>>
>>> So why not just make bool a 4-byte value?  Using an integer to
>>> represent a boolean operation is just silly.
>>  Or pad them to 4 bytes where you can (local variable).
> 
> Honestly, I think I would be happy with a four-byte bool, in almost
> all circumstances.
> 
> For those rare cases where space is an issue, there could be a second
> type, bool8, implicitly castable to and from bool, but you wouldn't
> use that by default; you'd only use it in structs where you needed to
> pack stuff tight.

Instead of having a separate type, why not just use a (u)byte in those 
cases? That's gotta be rarer than the cases where you'd want to use an 
int for a bool, so while it's the same problem, the incidence of the 
problem is reduced while not adding yet another data type that may be 
unclear for new users



More information about the Digitalmars-d mailing list