On Saturday, 11 May 2019 at 07:53:36 UTC, Mike Parker wrote:
Anyone interested in the AGM can watch it at the following link. You can leave feedback there, in IRC, or in Discord.

https://youtu.be/cpTAtiboIDs

Regarding the discussion of how bool is handled...

It's a one bit integer so it should behave like a one bit integer
https://www.youtube.com/watch?v=cpTAtiboIDs#t=2h17m50s

Wouldn't entirely say that, someone already pointed out the ++ operator but it does not behave like an integer in other respects either.

It does not overflow the same way an integer does, max + 1 -> 0. A 1-bit integer can only hold two values, 0/1. 1 + 1 should equal 0, but instead it equals 1. It is already a special case. Converting any integer will result in the bool being set to 1, the only time it isn't is when the integer is zero. Not like a 1-bit integer would.

    writeln( cast(ubyte) (ubyte.max + 1) );  // 0
    writeln( cast(ushort)(ushort.max + 1) ); // 0
    writeln( cast(uint)  (uint.max + 1) );   // 0
    writeln( cast(ulong) (ulong.max + 1) );  // 0
    writeln( cast(bool)  (bool.max + 1) );   // 1 (true)



Maybe you got too many overloads and what are you trying to do with those overloads that it would matter that it called a different overload
https://www.youtube.com/watch?v=cpTAtiboIDs#t=2h20m42s

I've seen it a few times, if you just a simple variant or some sort of generic script type to be used. You don't need "too many overloads" it literally takes 2, the minimum number of overloads for there to be an overload.


struct SomeVariantOrScriptTypeGeneric {
    enum Type { Bool, Long, }

    Type type;
    union { bool bool_; long long_; }

    this( bool ) { type = Type.Bool; }
    this( long ) { type = Type.Long; }
}

enum int a = 1;
enum int b = 2;

SomeVariantOrScriptTypeGeneric v = b - a; // type == Bool

Sure it is convenient to have some properties of bool also be similar to an integer, but it can definitely not be swapped in to be used like a 1-bit integer and there are already plenty of special rules for it.


  • DConf 2019 AGM Lives... Mike Parker via Digitalmars-d-announce
    • Re: DConf 2019 ... Exil via Digitalmars-d-announce
      • Re: DConf 2... Mike Franklin via Digitalmars-d-announce
        • Re: DCo... Nick Sabalausky (Abscissa) via Digitalmars-d-announce
        • Re: boo... Walter Bright via Digitalmars-d-announce
          • Re:... Nick Sabalausky (Abscissa) via Digitalmars-d-announce
            • ... Kagamin via Digitalmars-d-announce
              • ... Mike Franklin via Digitalmars-d-announce
                • ... Andrei Alexandrescu via Digitalmars-d-announce
                • ... Mike Franklin via Digitalmars-d-announce
                • ... Andrei Alexandrescu via Digitalmars-d-announce
                • ... Mike Franklin via Digitalmars-d-announce

Reply via email to