===?大家对clr的泛型实现方法有什么看法,欢迎发言?===

fixopen 2003-07-15 11:29:36
同标题。
...全文
87 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mydup 2003-07-30
  • 打赏
  • 举报
回复
同意fixopen
fixopen 2003-07-17
  • 打赏
  • 举报
回复
When a generic class is compiled, there is actually nothing different between it and a regular class. Indeed, the result of the compilation is nothing but metadata and intermediate language (IL). The IL is, of course, parameterized to accept a user-supplied type somewhere in code. How the IL for a generic type is used differs based on whether or not the supplied type parameter is a value or reference type.

When a generic type is first constructed with a value type as a parameter, the run-time creates a specialized generic type with the supplied parameter (or parameters) substituted in the appropriate places in the IL. Specialized generic types are created once for each unique value type used as a parameter.

不知道是不是C#范型的实现方法?
bm1408 2003-07-16
  • 打赏
  • 举报
回复
no meaning!
mechgoukiteng 2003-07-16
  • 打赏
  • 举报
回复
不是不关心

是以前没有接触过,只知道最基本的概念
fixopen 2003-07-16
  • 打赏
  • 举报
回复
没有人关心么?
fixopen 2003-07-15
  • 打赏
  • 举报
回复
我自己觉得跟计算机体系中的数据标签有关系。
我们都知道,计算机体系中,最初的指令都是数据相关的,后来发展出向量机,也仅仅是把一条指令施加到多条数据上,或者可以说是增加了一种数据类型,并没有本质的变化,后来发展出了数据标记的概念,指令已经仅仅是一种契约标记,数据带着自己的类型标记,由译码器来翻译成具体的操作。
CLR的泛型实现会不会使这个思想的延续,它在我们现存的硬件上如何模拟出它的虚机器的。这样的虚机器会不会已经为函数式语言打开了方便之门?
fixopen 2003-07-15
  • 打赏
  • 举报
回复
没有人感兴趣么?据说它的实现跟Java的实现是不一样的。JVM级别的指令是iload(or loadi),iadd(or addi)等与类型相关的指令集。而CLR却不是这样的,所以Java的泛型是在编译器翻译为字节码是通过添加类型转换来实现的,而C#的实现却不是如此。所以现在甚至把函数式语言OCaml一直到.net framework上来了,叫什么F#。希望大家发表看法。

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧