静态类继承,泛化 [英] static class inheritance, generalized

查看:59
本文介绍了静态类继承,泛化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个令人信服的例子,说明需要语言

功能,完全支持泛型,介绍所有静态成员和

嵌套当前名称搜索范围内的另一种类型。


即一个非常简单的应用程序将是


类ManyComputations

$

调用System.Math;


... z = Sin(3 * x)+ Log(y); //不需要限定符

}


这提供了从静态类继承的超集。概念,

没有实际使用继承或与密封冲突。


所有C#专家都被邀请加入讨论中

microsoft.public.dotnet.languages.vc在标题为howto decouple in

..NET?的帖子中。熟悉C ++ / CLI是一个明确的优点。


谢谢。

I''m trying to construct a compelling example of the need for a language
feature, with full support for generics, to introduce all static members and
nested classes of another type into the current name search scope.

i.e. a very simple application would be

class ManyComputations
{
calling System.Math;

... z = Sin(3*x) + Log(y); // qualifiers not needed
}

This provides a superset of the "inherit from a static class" concept,
without actually using inheritance or conflicting with "sealed".

All C# experts are invited to join the discussion over in
microsoft.public.dotnet.languages.vc in the thread titled "howto decouple in
..NET?" Some familiarity with C++/CLI is a definite plus.

Thanks.

推荐答案

Ben Voigt [C ++ MVP]< rb*@nospam.nospamwrote:
Ben Voigt [C++ MVP] <rb*@nospam.nospamwrote:

我正在尝试构建一个令人信服的语言需求示例

功能,完全支持泛型,将所有静态成员和

另一种类型的嵌套类引入当前名称搜索范围。


即非常简单的应用程序将是


类ManyComputations

{

调用System.Math;


... z = Sin(3 * x)+ Log(y); //不需要限定符

}


这提供了从静态类继承的超集。概念,

没有实际使用继承或与密封冲突。
I''m trying to construct a compelling example of the need for a language
feature, with full support for generics, to introduce all static members and
nested classes of another type into the current name search scope.

i.e. a very simple application would be

class ManyComputations
{
calling System.Math;

... z = Sin(3*x) + Log(y); // qualifiers not needed
}

This provides a superset of the "inherit from a static class" concept,
without actually using inheritance or conflicting with "sealed".



因为它实际上不是继承,我会尽量避免使用

这个词。

Because it''s not actually inheritance, I''d try to avoid using the term
wherever possible.


所有C#专家都被邀请参加

microsoft.public.dotnet.languages.vc讨论,标题为howto decouple in

.NET?"熟悉C ++ / CLI是一个明确的优点。
All C# experts are invited to join the discussion over in
microsoft.public.dotnet.languages.vc in the thread titled "howto decouple in
.NET?" Some familiarity with C++/CLI is a definite plus.



我会看看我是否有时间加入。


MS *可能*的一个原因*想要这样做 - Java有它:)

使用的语法也很好 - 静态导入。相当于

将是静态使用:


静态使用System.Math;


我不会建议在课堂上做这件事 - 我会用

其余的使用陈述。


-

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

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

I''ll see if I''ve got time to join in.

One reason MS *might* want to do it - Java has it :)
The syntax used is quite nice, too - static import. The equivalent
would be static using:

static using System.Math;

I wouldn''t suggest doing it within a class though - I''d put it with the
rest of the using statements.

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




" Jon Skeet [C#MVP]" < sk *** @ pobox.com写了留言

新闻:MP ********************* @ msnews.microsoft.com 。 ..

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..

Ben Voigt [C ++ MVP]< rb *@nospam.nospamwrote:
Ben Voigt [C++ MVP] <rb*@nospam.nospamwrote:

> ;我正在尝试构建一个令人信服的例子,说明需要语言
功能,完全支持泛型,将所有静态成员

嵌套类引入其中当前名称搜索范围。

即一个非常简单的应用程序将是类许多计算
{
调用System.Math;

... z = Sin(3 * x)+日志(y)基//不需要限定词


这提供了从静态类继承的超集。概念,
没有实际使用继承或与密封冲突。
>I''m trying to construct a compelling example of the need for a language
feature, with full support for generics, to introduce all static members
and
nested classes of another type into the current name search scope.

i.e. a very simple application would be

class ManyComputations
{
calling System.Math;

... z = Sin(3*x) + Log(y); // qualifiers not needed
}

This provides a superset of the "inherit from a static class" concept,
without actually using inheritance or conflicting with "sealed".



因为它实际上不是继承,我会尽量避免使用

这个词。


Because it''s not actually inheritance, I''d try to avoid using the term
wherever possible.


>所有C#专家都被邀请参加
microsoft.public.dotnet.languages.vc中题为howto decouple
的帖子的讨论在
.NET?熟悉C ++ / CLI是一个明确的优点。
>All C# experts are invited to join the discussion over in
microsoft.public.dotnet.languages.vc in the thread titled "howto decouple
in
.NET?" Some familiarity with C++/CLI is a definite plus.



我会看看我是否有时间参加。


MS *可能*的一个原因*想要这样做 - Java有它:)

使用的语法也很好 - 静态导入。相当于

将是静态使用:


静态使用System.Math;


我不会建议在课堂上这样做 - 我会把它与

其余的using语句一起使用。


I''ll see if I''ve got time to join in.

One reason MS *might* want to do it - Java has it :)
The syntax used is quite nice, too - static import. The equivalent
would be static using:

static using System.Math;

I wouldn''t suggest doing it within a class though - I''d put it with the
rest of the using statements.



哦,它必须在课堂上提供。绝对肯定。但是我已经在另一组中解释了原因。如果它也在命名空间范围内工作,那并不是说它不会很好。

Oh, it has to be available in a class. Absolutely positively. But I''ve
already explained why in the other group. That''s not to say it wouldn''t be
nice if it also worked at namespace scope.


>

-

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

如果回复该群组,请不要给我发邮件
>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too



Ben Voigt [C ++ MVP]< rb*@nospam.nospamwrote:
Ben Voigt [C++ MVP] <rb*@nospam.nospamwrote:

我不建议在课堂上这样做 - 我会把它与

其余的using语句一起使用。
I wouldn''t suggest doing it within a class though - I''d put it with the
rest of the using statements.



哦,它必须在课堂上提供。绝对肯定。但是我已经在另一组中解释了原因。如果它也在命名空间范围内工作,那并不是说它不会是好的。


Oh, it has to be available in a class. Absolutely positively. But I''ve
already explained why in the other group. That''s not to say it wouldn''t be
nice if it also worked at namespace scope.



看起来我们正在谈论*完全*不同的事情。您给出的能够使用Sin和Log方法而不需要进一步限定的
示例与您在

中的愿望非常不同在VC组中表达,据我所知(这远远不是
)。


用于制作静态成员的目的一种类型可用于

另一种没有资格的类型,添加使用

语句的功能很好。


我是不是*完全*确定你在VC组中要求的是什么,但是它好像b $ b似乎延伸了*方式*过去那个。


我想这将是一个比在

C ++小组中更富有成效的讨论 - 如果你建议使用C#功能,那么这个话题也会更多。

而不是C ++功能。


-

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

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

It looks like we''re talking about *completely* different things. The
example you gave of being able to use the Sin and Log methods without
further qualification are very different from the desires you have in
expressed in the VC group, as far as I understand them (which isn''t
terribly far).

For the purposes of making static members from one type available in
another type without qualification, adding the capability to using
statements is fine.

I''m not *entirely* sure what you''re asking for in the VC group, but it
seems to extend *way* past that.

I think it would be a much more fruitful discussion here than in the
C++ group - and more on-topic too, if you''re suggesting a C# feature
rather than a C++ feature.

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


这篇关于静态类继承,泛化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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