Raja Krishnaswamy and Jesse Kaplan: CLR 4 - Inside No-PIA
- Posted: May 27, 2009 at 8:43 AM
- 43,772 Views
- 7 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
So this Type Equivalence... are we talking about something that might be the basis of "static duck typing" as in C++ templates?
e.g. public static void Foo<T>(T arg) where T : IBar
Currently this means T must implement IBar... will type equivalence open up the possibility that T could be something that satisfies the method signatures of IBar, but doesn't necessarily have to implement it?
That would be great. Suppose I have to work with several third party classes, they all have a method:
void Log(string str)
but they don't implement any common interface. I might write:
interface ICanLog { void Log(string str); }
Would I then (with some attribute magic?) be able to assign instances of those third party classes to variables/parameters of that interface type?
ICanLog canLog = new ThirdPartyThing();
Bah... based on this, I'm guess the answer is no.
If you think about it, type equivalence is about matching two essentially 'identical' types that are not actually the same clr type.. which is different to duck typing which is more of a.. these types are different (even outside of the clr type), but they look similar.
The key difference tending to be that type equivalence is about allowing a boundary to be broken where two types are intending to be the same thing, but duck typing is less about the types intending to be the same, but just looking the same.
Personally I don't see a lot of places where duck typing would be useful.. tends to be a simple proxy class fits most scenarios.
It becomes more of a problem as a project evolves over several years, especially with independently developed components going into it.
Over time, the number of cases where proxy classes are needed grows until they blot out the intention of the "actual" code, which is when a language feature becomes valuable.
Does this embedding only work if you use a VSTO template in Visual Studio?
For example, I'm working on project right now that's a WPF application which uses the PIAs to extract data from Excel for use by another application, and my app is basically a bridge for these programs, is this scenario supported?
Don't we have type embedding already, of sorts. Open up Reflector load say, the Word PIA and cut and paste the class interfaces you need into your project. This then gives you masive flexibility to modify the interfaces, leave member out and/or redefine members so they do not throw exceptions, but return hResults. Then you can use Compiler extensions to bolt on Word 12 interfaces and methods onto the Word 10/11 Object model. This is a very usefull trick
Helpful
Remove this comment
Remove this thread
close