bool <=> int. WTF. (DIP0015)

Les De Ridder les at lesderid.net
Tue Jul 2 17:43:27 UTC 2019


On Tuesday, 2 July 2019 at 17:04:24 UTC, Jonathan M Davis wrote:
> On Tuesday, July 2, 2019 6:06:00 AM MDT a11e99z via 
> Digitalmars-d wrote:
>> [...]
>
> Basically, unlike most of us, Walter doesn't see any real 
> difference between a bit and a bool even conceptually and thus 
> thinks bool should just be a one bit integer type. So, for the 
> most part, that's actally how bool works in D. At some point, 
> either someone convinced him to make ++ illegal on bools or 
> managed to get a PR in that did, and as I understand it, he 
> regrets that that happened. DIP 1015 was proposed to fix how 
> bool works so that it's no longer treated like an integer type, 
> but Walter and Andrei rejected it. It's been discussed to death 
> already, and it's clearly not going to change. As is the case 
> with many (most?) languages, ultimately, language decisions in 
> D are not a democracy. D is Walter's language, and he has the 
> final say. He frequently has made great decisions with D. Many 
> of us do not think that he did in particular this case, but 
> it's still his decision, and it's quite clear at this point 
> that he's not going to change his mind on this topic. So, if 
> you want to use D, you're basically just going to have to learn 
> to put up with the idea that bool is effectively bit.
>
> - Jonathan M Davis

I'm new to this discussion, but:

Can we fix the implementation and the spec, then? Walter's 
opinion is
clear, so can we move on? People are still free to write a new 
DIP to
convince the language maintainers, but the current state of bool 
seems
inconsistent.

This is in the spec[1] but fails for bool:

     assert(T.max + 1 == T.min, T.stringof);
     assert(T.min - 1 == T.max, T.stringof);

The spec also doesn't[2] consider `true` and `false` to be integer
literals, yet they are of type bool and they can be used as the 
rhs of
an int assignment. The grammar currently doesn't even consider 
them to
be literals[3].

Why do complement expressions[4] not work on bool?

To me something feels clearly wrong here.

[1] https://dlang.org/spec/expression.html#add_expressions 
(paragraph 7)
[2] https://dlang.org/spec/lex.html#IntegerLiteral
[3] https://dlang.org/spec/grammar.html#PrimaryExpression
[4] https://dlang.org/spec/expression.html#complement_expressions


More information about the Digitalmars-d mailing list