Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Go-like duck typing interfacing

8 views
Skip to first unread message

Markus Schaber

unread,
Nov 15, 2009, 3:30:01 PM11/15/09
to
Hello,

I just stumbled across the "Go" language from google. Especially, I
like the duck-typing approach to interfaces.

Now my question: Is it even possible to implement such static duck
typing using the CLR?

Managed C++ templates seem to look similary, but they work by the
compiler generating the code for the all uses, so the CLR just sees
non-generic CIL code.

In C#, classes and structs must explicitly instantiate interfaces.

IronPython and IronRuby work by dynamic dispatching at runtime.

This makes me think that compile-time interface duck typing is not
possible using CLR / CLI, that it is not possible to express this idiom
using .NET.

Is my assumption correct? Is it different in .NET 4.0?

I also guess that the ability to express such an idiom might be useful
for generic constraints, or extension methods.

Thanks for your patience,
Markus
--
"A patched buffer overflow doesn't mean that there's one less way
attackers can get into your system; it means that your design process
was so lousy that it permitted buffer overflows, and there are probably
thousands more lurking in your code." - Bruce Schneier


0 new messages