CTP里的C# 4离“现在”的进度果然差好远啊。我[url=http://rednaxelafx.iteye.com/blog/260206]上一篇[/url]描述的C# 4方法动态分派的逻辑只适用于CTP,现在规则变成了这样:
Sam Ng: [url=http://blogs.msdn.com/samng/archive/2008/11/09/dynamic-in-c-iii-a-slight-twist.aspx]Dynamic in C# III: A slight twist[/url]
[quote="Sam Ng"][b]This means that for all arguments not statically typed[/b] [color=blue]dynamic[/color], [b]the compile time types will be used, regardless of their runtime types.[/b][/quote]
现在的说法是,只要参数不是[color=blue]dynamic[/color]类型的变量,就会跟静态编译一样采用变量的静态类型作为重载解析的依据。用回前面用过的例子,goo.Bar( da, b );就会是用Goo.Bar(A, A)而不是CTP里表现出来的Goo.Bar(A, B)。新的决定对避免混乱应该说是有好处的,以前熟悉C#的人也不会一不小心就用错了重载版本。
有机会再详细说说……CTP里的C# 4问题多多,有好些地方都把我吓得不行,诶……
Sam Ng: [url=http://blogs.msdn.com/samng/archive/2008/11/09/dynamic-in-c-iii-a-slight-twist.aspx]Dynamic in C# III: A slight twist[/url]
[quote="Sam Ng"][b]This means that for all arguments not statically typed[/b] [color=blue]dynamic[/color], [b]the compile time types will be used, regardless of their runtime types.[/b][/quote]
现在的说法是,只要参数不是[color=blue]dynamic[/color]类型的变量,就会跟静态编译一样采用变量的静态类型作为重载解析的依据。用回前面用过的例子,goo.Bar( da, b );就会是用Goo.Bar(A, A)而不是CTP里表现出来的Goo.Bar(A, B)。新的决定对避免混乱应该说是有好处的,以前熟悉C#的人也不会一不小心就用错了重载版本。
有机会再详细说说……CTP里的C# 4问题多多,有好些地方都把我吓得不行,诶……