<div dir="ltr">2013/4/28 Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5">On 4/27/2013 3:58 PM, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On 4/27/2013 1:26 PM, kenji hara wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I don't have so much knowledge about C/C++ language spec, but for the issue case<br>
C++ makes "ambiguous error".<br>
</blockquote>
<br>
That's because C++ regards an implicit conversion of 1 to bool or long as having<br>
equal weight, and it has no further mechanism.<br>
<br>
</blockquote>
<br></div></div>
Note that the following is also ambiguous in C++:<br>
<br>
void foo(bool b) { }<br>
void foo(long l) { }<br>
<br>
void main() {<br>
foo(3);<br>
}<br>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra" style>Yes, but all C++ users would accept the behavior - In C++, all integer types are treated as bool type under the rule that zero/non-zero value is equivalent to false /true. From the view of D user, it looks inconvenient, but there is still few and consistent rule.</div>
<div class="gmail_extra" style>On the other hand, D looks like having *special rule* of 0 and 1 literal for boolean type. Even if the underlying rule is sane (partial ordering rule and VRP), the combination makes weird behavior.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>----</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>Now I doubt that this problem comes from the history of D and wrong dmd implementation. In early D1 age, we had had 'bit' type which exactly have one bit value 0 and 1. After the while, the name 'bit' changed to 'bool'. At that point, 'bool' was kept the characteristics that it is one of the integer types - even though we should discard it. Right?</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>VRP is a new concept that introduced in D2 age. But, maybe, the combination of bool and VRP had not been considered enough. So now problem is appeared there.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>Now it feels to me that is a debt from D1.<br></div><div><br></div><div style>Kenji Hara</div></div>