DConf 2019 AGM Livestream

Exil Exil at gmall.com
Sat May 11 20:35:40 UTC 2019


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.




More information about the Digitalmars-d-announce mailing list