April 28, 2013
On 4/28/2013 1:58 PM, Mehrdad wrote:
> The entire confusion in this thread is because you're mixing up the two.

I know exactly what you're talking about, and I haven't seen any confusion from other posters, either.
April 28, 2013
On Sunday, 28 April 2013 at 21:17:39 UTC, Walter Bright wrote:
> On 4/28/2013 1:58 PM, Mehrdad wrote:
>> The entire confusion in this thread is because you're mixing up the two.
>
> I know exactly what you're talking about, and I haven't seen any confusion from other posters, either.


If I just told you why Boolean arithmetic isn't integer arithmetic, and you know exactly what I'm talking about, then why do you say Booleans are integers?

Isn't that self-contradictory?
April 28, 2013
On 04/28/2013 10:54 PM, Mehrdad wrote:
> On Sunday, 28 April 2013 at 19:19:53 UTC, Walter Bright wrote:
>> ...
>>
>> To reiterate, history amply shows that if 'true' and 'false' are not
>> there, then people will define them themselves, inconsistently, and
>> the end result is not helpful to anybody.
>
>
> History also amply shows that having a 'bool' data type that tries to
> behave like a 'bit' data type also leads to frustration.
>
> See:
> - This thread

"History".

> - std::vector<bool>

The issues surrounding vector<bool> are entirely unrelated.
April 28, 2013
On 04/28/2013 11:22 PM, Mehrdad wrote:
> On Sunday, 28 April 2013 at 21:17:39 UTC, Walter Bright wrote:
>> On 4/28/2013 1:58 PM, Mehrdad wrote:
>>> The entire confusion in this thread is because you're mixing up the two.
>>
>> I know exactly what you're talking about, and I haven't seen any
>> confusion from other posters, either.
>
>
> If I just told you why Boolean arithmetic isn't integer arithmetic, and
> you know exactly what I'm talking about, then why do you say Booleans
> are integers?
>
> Isn't that self-contradictory?

He is saying bool is an integral type in D. (i.e. it can be promoted to 'int' in order to support integer arithmetic.)
April 28, 2013
Yes, as Andrei mentioned, it is sometimes useful. But, at least during overload resolution, it must not occur.

Kenji Hara


2013/4/29 Timon Gehr <timon.gehr@gmx.ch>

> On 04/28/2013 11:22 PM, Mehrdad wrote:
>
>> On Sunday, 28 April 2013 at 21:17:39 UTC, Walter Bright wrote:
>>
>>> On 4/28/2013 1:58 PM, Mehrdad wrote:
>>>
>>>> The entire confusion in this thread is because you're mixing up the two.
>>>>
>>>
>>> I know exactly what you're talking about, and I haven't seen any confusion from other posters, either.
>>>
>>
>>
>> If I just told you why Boolean arithmetic isn't integer arithmetic, and you know exactly what I'm talking about, then why do you say Booleans are integers?
>>
>> Isn't that self-contradictory?
>>
>
> He is saying bool is an integral type in D. (i.e. it can be promoted to 'int' in order to support integer arithmetic.)
>


April 28, 2013
On Sunday, 28 April 2013 at 21:29:06 UTC, Timon Gehr wrote:
> On 04/28/2013 10:54 PM, Mehrdad wrote:
>> - std::vector<bool>
>
> The issues surrounding vector<bool> are entirely unrelated.


Huh? It's entirely related.
The fact that sizeof(bool) * 8 != sizeof(byte) is what causes problems in vector<bool> (can't treat them like other types, which we can address directly), and it's also one of the asymmetries bool has with integers in D (and any other language).

Different situation, same cause: bool doesn't behave like an integer.


>> Isn't that self-contradictory?

> He is saying bool is an integral type in D. (i.e. it can be promoted to
'int' in order to support integer arithmetic.)

I thought we just established that boolean logic isn't integer logic?
April 28, 2013
On 04/28/2013 11:51 PM, Mehrdad wrote:
> On Sunday, 28 April 2013 at 21:29:06 UTC, Timon Gehr wrote:
>> On 04/28/2013 10:54 PM, Mehrdad wrote:
>>> - std::vector<bool>
>>
>> The issues surrounding vector<bool> are entirely unrelated.
>
>
> Huh? It's entirely related.
> The fact that sizeof(bool) * 8 != sizeof(byte) is what causes problems
> in vector<bool>

Exactly. This is not the problem here.

> (can't treat them like other types, which we can address
> directly), and it's also one of the asymmetries bool has with integers
> in D (and any other language).
>
> Different situation, same cause: bool doesn't behave like an integer.
>

The issue discussed here is that some think it behaves too much like an integer.

>
>>> Isn't that self-contradictory?
>
>> He is saying bool is an integral type in D. (i.e. it can be promoted to
> 'int' in order to support integer arithmetic.)
>
> I thought we just established that boolean logic isn't integer logic?

Please make sure your statements make sense.

April 28, 2013
On 4/28/13 5:41 PM, kenji hara wrote:
> Yes, as Andrei mentioned, it is sometimes useful. But, at least during
> overload resolution, it must not occur.
>
> Kenji Hara

Well the problem has other ramifications beyond bool. Consider:

import std.stdio;

int fun(short v1) { return 1; }
int fun(long v1) { return 2; }

void main(string[] args)
{
    writeln(fun(10_000));
    writeln(fun(100_000));
}

This prints "1 2". So the behavior of bool in this case is consistent with the behavior of other integral types.


Andrei
April 28, 2013
On Sunday, 28 April 2013 at 22:40:33 UTC, Andrei Alexandrescu wrote:
> On 4/28/13 5:41 PM, kenji hara wrote:
>> Yes, as Andrei mentioned, it is sometimes useful. But, at least during
>> overload resolution, it must not occur.
>>
>> Kenji Hara
>
> Well the problem has other ramifications beyond bool. Consider:
>
> import std.stdio;
>
> int fun(short v1) { return 1; }
> int fun(long v1) { return 2; }
>
> void main(string[] args)
> {
>     writeln(fun(10_000));
>     writeln(fun(100_000));
> }
>
> This prints "1 2". So the behavior of bool in this case is consistent with the behavior of other integral types.
>
>
> Andrei

It's not entirely the same. You provided two overloads of integral types. bool is not integral.

And yes, I personally don't like this either, but I could live with it. Buy fun(1) calling the bool overload? It's ridiculous.

"Code that looks correct should be correct". fun(1) calling bool overload sure looks and is correct.
April 28, 2013
On Sunday, 28 April 2013 at 22:25:43 UTC, Timon Gehr wrote:
> On 04/28/2013 11:51 PM, Mehrdad wrote:
>> On Sunday, 28 April 2013 at 21:29:06 UTC, Timon Gehr wrote:
>>> On 04/28/2013 10:54 PM, Mehrdad wrote:
>>>> Isn't that self-contradictory?
>>
>>> He is saying bool is an integral type in D. (i.e. it can be promoted to 'int' in order to support integer arithmetic.)
>>
>> I thought we just established that boolean logic isn't integer logic?
>
> Please make sure your statements make sense.


Huh?

Walter says bool is an integer, but he understands that boolean variables don't follow integer logic.

That makes no sense, it's like saying "I understand the sky is blue, but the sky is red."



What part of this is not making sense to you?