1 matches bool, 2 matches long

kenji hara k.hara.pg at gmail.com
Sat Apr 27 13:31:06 PDT 2013


(This is a quotation from
http://d.puremagic.com/issues/show_bug.cgi?id=9999<http://d.puremagic.com/issues/show_bug.cgi?id=9999#c4>
)

> I do not agree with this enhancement. First off, making special cases for
> partial ordering takes a simple, straightforward idea and turns it into a
> potential morass of conflicting cases that we'll be stuck with forever.
> Secondly, the only issue here is whether '1' should be implicitly
convertible
> to 'bool'.

Walter, I can understand your concern. But I think it would not be so big.
Because the possibility of extending basic type set is not so much in the
future.

Keeping language spec simple is necessary, but also reduce special rule for
humans is also important. This is a much rare case that is the mismatch
between
simple rule and natural behavior for human. Fixing this issue would be
valuable
for many D users.

Logically 'true' and  'false' are not related to any integer values.
Although
it is widely known and used, considering boolean type as a kind of
specialized
integer type is not general - it is implementation detail. At least it comes
from C language. In old ages, boolean type had not been supported properly
in
many programming languages, but today, languages which not supporting it
would
not regarded as useful. D is a modern programming language, so more proper
behavior for boolean type is necessary.

As one of its goal, D should aim the successor of C. Therefore, we cannot
drop
the implicit conversion between bool and other integer types which inherited
from C.
But this problem behavior is definitely unnatural for many programmers, and
would enforce to study bad know-how for them. Loosing future users for the
compiler simplicity is not good decision. Of course, balance is necessary
there, but I think this is necessary complexity.

Kenji Hara


2013/4/28 kenji hara <k.hara.pg at gmail.com>

> 2013/4/28 Walter Bright <newshound2 at digitalmars.com>
>
>> On 4/27/2013 8:11 AM, kenji hara wrote:
>>
>>> Walter, now I changed my opinion. It seems not correct that being
>>> regarded bool
>>> type as one of the integer.
>>> How about?
>>>
>>
>> Both C and C++ regard bool as an integer, and implicitly convert 1/0 to
>> true/false.
>>
>> What C++ doesn't have is VRP and partial ordering of functions. (But it
>> does have partial ordering of template functions.)
>>
>
> I'm not argue that we should remove the implicit conversion from 1/0 to
> bool.
>
> I don't have so much knowledge about C/C++ language spec, but for the
> issue case C++ makes "ambiguous error".
> Contrary of that, D's current behavior looks to me it is going back to
> past.
>
> Kenji Hara
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130428/a0da260b/attachment-0001.html>


More information about the Digitalmars-d mailing list