D arithmetic problem

davidl davidl at nospam.org
Tue Jun 2 20:06:50 PDT 2009


在 Wed, 03 Jun 2009 10:58:32 +0800,Tim Matthews <tim.matthews7 at gmail.com>  
写道:

> davidl wrote:
>
>> I mean the first behavior can cause problems.
>
> Ohh sorry.
>
>> I doubt any coder would try to get that result by writing that piece of  
>> code. I ported some C# source to D, and I got this semantic different  
>> issue.
>>
>
>   It is probably mostly used for dealing with binary data but D has no  
> other way of specifying a number that is only 1 byte except the char but  
> that would be a misuse of the type system unless ported from c/c++. Just  
> a few gotchas off the top of my head:
>
> D     C#
> ------------
> ubyte   Byte
> byte    SByte
> wchar   Char

Perhaps, it's because of my mistranslating all Byte to byte directly.
Nonetheless, the first behavior is not impressive. I innately dislike  
that. Because I try to deal with a type with one byte by using Or  
operator, I get it promoted to int. That implicitly cast sounds awful.

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list