On Sunday, 28 April 2013 at 13:38:53 UTC, Andrei Alexandrescu wrote:
[...]
If enough differences accumulate to make bool quite a different type from a regular integral, then the matter of overloading with long, conversion from literals 1 and 0 etc. may be reopened. Even then, it would be a difficult decision.

I agree with most of what you said in your full post, except that in the quote above you are suggesting that there's a difficult decision to be made in the case of bool being it's own type rather than an integral type.

The opposite should be the case, where the decision to keep it as an integral is a difficult to defend.

I don't see where the difficulty is, because unless bool can exactly be treated as an integral, then it simply is not an integral, and unless it is an integral, it cannot be freely interchanged with the integrals.

The arguments in defense if bool as an integral are IMO weak.

For example, Walter mentioned the case of char successfully being treated as an integral type rather than a special case "char' type. However, are there any differences between what char does and what byte does that interfere with each other? If char performs exactly like a integral type, then you can convincingly argue that it is an integral type.

Can the same thing with char be said about bool? No. You can only say that bool does share some, but not all the characteristics if an integral.

The other argument in favor boils down to a matter of convenience under some circumstances. Yes, there are a few cases where it is advantageous to interchange boolean 'true' and 'false' with integral 1 and 0, however the vast majority of uses do not rely on such an interchange, and even if such interchanges are used often, bool still has significant differences of behavior that exclude it from being considered as a fully interchangeable integral type (eg truncation behavior and differences with operators).

The best you can argue for, is that under some situations, bool should be freely interchanged with regular integrals, however that's not going to be true for all cases.

The conclusion ought to be that unless bool can be adjusted into behaving exactly like all the other integrals, then it simply cannot be freely interchanged as an integral in all cases, i.e., maybe OK in some cases, but certainly not all.

--rt

Reply via email to