没有运营商在ushort上定义 [英] No operators defined on ushort

查看:101
本文介绍了没有运营商在ushort上定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想开始技术讨论C#没有定义其他整数类型的数学运算符而不是
int。


在C#中,以下简单的事情是不可能的:


ushort a,b,c;


a = b = 0;

c = a - b;


无论你使用什么类型的整数数据,你都会总是得到一个错误不能

隐式转换为int。这是什么意思?如果语言

提供像byte或ushort这样的类型,我想使用它们。我希望看到

溢出错误,每当例程错误计算的东西。


编译器在这里做的是技术上和数学上不完整的。

它应该尽快修复。


任何人?


Axel Dahmen


Hi,

I want to start a technical discussion on the fact that C# doesn''t define
any mathematical operators on other integral types than int.

Simple things like the following just aren''t possible in C#:

ushort a,b,c;

a = b = 0;
c = a - b;

Whatever integral data type you use, you''ll always get an error "can''t
implicitly convert to int." What''s the purpose of this?? If the language
provides types like byte or ushort I want to use them. I want to see
overflow errors whenever routines miscalculate something.

What the compiler does here is technically and mathematically incomplete.
And it should be fixed ASAP.

Anyone?

Axel Dahmen


推荐答案



看看这些:

http://msdn.microsoft.com/library/de .. .vclrfshort.asp
http://msdn.microsoft.com/library/de...conversion.asp

" Axel Dahmen" <否**** @ NoOneKnows.de>在消息中写道

news:ex ************** @ tk2msftngp13.phx.gbl ...

Take a look at these:

http://msdn.microsoft.com/library/de...vclrfshort.asp
http://msdn.microsoft.com/library/de...conversion.asp
"Axel Dahmen" <No****@NoOneKnows.de> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...

我想开始一个技术讨论,事实上C#没有定义任何其他整数类型的数学运算符而不是int。

简单的事情,如下所示在C#中是不可能的:

ushort a,b,c;

a = b = 0;
c = a - b;

无论使用哪种整数数据类型,您总会收到错误无法隐式转换为int。这是什么意思?如果语言
提供像byte或ushort这样的类型,我想使用它们。我希望看到
溢出错误,每当例程错误计算的东西。

编译器在这里做的是技术上和数学上不完整的。
它应该尽快修复。

任何人?

Axel Dahmen
Hi,

I want to start a technical discussion on the fact that C# doesn''t define
any mathematical operators on other integral types than int.

Simple things like the following just aren''t possible in C#:

ushort a,b,c;

a = b = 0;
c = a - b;

Whatever integral data type you use, you''ll always get an error "can''t
implicitly convert to int." What''s the purpose of this?? If the language
provides types like byte or ushort I want to use them. I want to see
overflow errors whenever routines miscalculate something.

What the compiler does here is technically and mathematically incomplete.
And it should be fixed ASAP.

Anyone?

Axel Dahmen



嗯,Yves,我知道这些文件。虽然他们解释了影响本身

以及如何处理C#的不完整数据类型实现,但他们不会讨论缺少运算符渲染C#的事实。不完整。


这是我的观点:在数学和信息学科学中,一个
本地标量数据类型建立了一个K向量空间。 - 在C#中,只有

整数数据类型满足此要求。到目前为止,所有其他完整的C#数据

类型都已瘫痪。


关于这方面,C#有问题。要获得真正全面的(一种有效的)语言,C#需要为所有本地标量数据添加运算符

类型。


我可能错了,但是如果我不是,那么讨论中的论点

应该导致将缺少的运算符实现到C#中。


-----------------------------------

" Yves Tourchot" ; <德**************** @ sympatico.ca> schrieb im Newsbeitrag

新闻:ez ******************** @ news20.bellglobal.com。 ..
Well, Yves, I know these documents. Though they explain the effect itself
and how to deal with C#''s incomplete data type implementation, they don''t
discuss the fact that the missing operators render C# incomplete.

Here is my point of view: Mathematically and in Informatics science, a
native scalar data type establishes a K vector space. - In C#, only the
integer data type fulfills this requirement. All other integral C# data
types are crippled so far.

Regarding this aspect, C# is faulty. To get a truly comprehensive (a
"valid") language, C# needs to add operators to all native scalar data
types.

I might be wrong, but in case I''m not, the arguments in this discussion
should lead to implementing the missing operators into C#.

-----------------------------------
"Yves Tourchot" <de****************@sympatico.ca> schrieb im Newsbeitrag
news:ez********************@news20.bellglobal.com. ..

看看这些:

http://msdn.microsoft.com/library/de...us/csref/html/

vclrfshort.asp
http://msdn.microsoft.com/library/de...us/csref/html/

vclrfimplicitnumericconversion.asp

Axel Dahmen <否**** @ NoOneKnows.de>在消息中写道
新闻:ex ************** @ tk2msftngp13.phx.gbl ...

Take a look at these:

http://msdn.microsoft.com/library/de...us/csref/html/
vclrfshort.asp http://msdn.microsoft.com/library/de...us/csref/html/
vclrfimplicitnumericconversion.asp

"Axel Dahmen" <No****@NoOneKnows.de> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...

我想开始一个关于C#没有
定义除int之外的其他整数类型的任何数学运算符这一事实的技术讨论。

以下简单的事情就是不是可能在C#中:

ushort a,b,c;

a = b = 0;
c = a - b;
无论您使用何种整数数据类型,您都会收到错误无法隐式转换为int。这是什么意思?如果语言
提供像byte或ushort这样的类型,我想使用它们。我希望看到
溢出错误,每当例程错误地计算一些东西。

编译器在这里做的是技术上和数学上
不完整。它应尽快修复。

任何人?

Axel Dahmen
Hi,

I want to start a technical discussion on the fact that C# doesn''t define any mathematical operators on other integral types than int.

Simple things like the following just aren''t possible in C#:

ushort a,b,c;

a = b = 0;
c = a - b;

Whatever integral data type you use, you''ll always get an error "can''t
implicitly convert to int." What''s the purpose of this?? If the language
provides types like byte or ushort I want to use them. I want to see
overflow errors whenever routines miscalculate something.

What the compiler does here is technically and mathematically incomplete. And it should be fixed ASAP.

Anyone?

Axel Dahmen





Axel Dahmen< No **** @ NoOneKnows.de>写道:
Axel Dahmen <No****@NoOneKnows.de> wrote:
嗯,伊夫,我知道这些文件。虽然他们解释了影响本身以及如何处理C#的不完整数据类型实现,但他们没有讨论丢失的运算符使C#不完整的事实。
原生标量数据类型建立K向量空间。 - 在C#中,只有
整数数据类型满足此要求。到目前为止,所有其他完整的C#数据类型都已瘫痪。

在这方面,C#有问题。要获得真正全面的(有效的)语言,C#需要为所有本地标量数据类型添加运算符。

我可能错了,但万一我不是,这个讨论中的论点
应该导致将缺少的运算符实现到C#中。
Well, Yves, I know these documents. Though they explain the effect itself
and how to deal with C#''s incomplete data type implementation, they don''t
discuss the fact that the missing operators render C# incomplete.

Here is my point of view: Mathematically and in Informatics science, a
native scalar data type establishes a K vector space. - In C#, only the
integer data type fulfills this requirement. All other integral C# data
types are crippled so far.

Regarding this aspect, C# is faulty. To get a truly comprehensive (a
"valid") language, C# needs to add operators to all native scalar data
types.

I might be wrong, but in case I''m not, the arguments in this discussion
should lead to implementing the missing operators into C#.




我认为这个讨论中的论点是如果他们关心的是有用性而不是学术上的完整性,那就更好了。


C#的非int数据类型是否瘫痪 ;似乎没有

已经阻止人们编写C#代码有效,是吗?问题

不应该是C#是否不完整,它是否可以是

可能*比它已经有用*更有用是。


我当然会有兴趣听到语言作者对

为什么做出这些选择,但是如果有一些合适的话

实际原因,我一个人在牺牲中没有问题

完整性对于有用性。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



I think the arguments in this discussion would be much better placed if
they were concerned with usefulness rather than academic completeness.

Whether or not C#''s non-int data types are "crippled" doesn''t seem to
have stopped people writing C# code which works, does it? The question
shouldn''t be whether or not C# is "incomplete", it''s whether it can be
made potentially *more* useful than it already is.

I would certainly be interested to hear from the language authors on
why these choices were made, but if there are some appropriate
practical reasons, I for one have no problem in sacrificing
"completeness" for "usefulness".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于没有运营商在ushort上定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆