object.opEquals return type

Janice Caron caron800 at googlemail.com
Sun Feb 24 09:18:27 PST 2008


On 24/02/2008, Edward Diener <eddielee_no_spam_here at tropicsoft.com> wrote:
>  I know you are saying that
>  having two types would enable the compiler to choose the most efficient,
>  but a compiler should be able to do this internally anyway without
>  creating the complication.

Right. I didn't mean to imply that bool8 or boo32 should necessarily
be exposed to the user (...although doing so would be harmless...).
The whole point is that the user would just write "bool" and the
compiler would does what was right for that situation.

So

    struct S
    {
        bool b; /* b is a bool8 */
    }

    bool f() /* f returns a bool32 */

    S s;
    s.b = f(); /* implicit cast happens */

As far as I can see, everything just works, efficiency is maintained,
and the programmer's intent is clear at all times.

I do agree with you that if Walter goes for this, bool8 and bool32
should be internal concepts, not normally exposed to the user.



More information about the Digitalmars-d mailing list