DIP 1017--Add Bottom Type--Final Review

Neia Neutuladh neia at ikeran.org
Tue Jan 22 06:57:24 UTC 2019


On Tue, 22 Jan 2019 06:29:41 +0000, Tobias Müller wrote:
> Take 'bool' as an example. It carries only one bit of dynami
> information, yet from the type itself you also know that it's no 'int'
> or pointer type which is definitely more than one bit of information.

Point of pedantry: bool is an integer type according to the type 
specialization rules, a more specific subtype of 'int'. It can participate 
in some arithmetic expressions, though it omits things like ++ and +=.

So you can write things like:

    i = i + true | ((true + true) ^^ (true + true + true) ^ false);

And this code uses the bool overload:

    void foo(bool b) { writeln("bool"); }
    void foo(short b) { writeln("ubyte"); }
    foo(cast(ubyte)0);

I'm not sure anyone but Walter thinks this is a good idea.


More information about the Digitalmars-d mailing list