Fabulous Adventures In Coding
Eric Lippert is a principal developer on the C# compiler team. Learn more about Eric.
Somehow it has happened again; people just keep on recording videos of me and putting them on the internet.
In these videos you find out what I look like when lit from above and behind. Kinda spooky. We should have made the room entirely dark and held a flashlight underneath my face. That would be, like, ten times scarier. Anyway, if you're interested in me blathering on about my favourite feature in C# 4, covariance and contravariance of interface and delegate types, here are two little demo videos: Part One, Part Two. (There seems to be some minor sound sync issues here and there, but it's not really a problem; most of the audio is voice-over.)
Charlie has been crazy busy getting these little videos together; here are some more of his recent efforts, including some good ones from my colleagues Chris and Sam talking about all the other far more awesome features of C# 4.0: dynamic interop, improved interop with Office, named and optional parameters, and so on. Links to all of our recent videos are here: http://blogs.msdn.com/charlie/archive/2009/10/19/community-convergence-lvi.aspx.
Have an amusing and safe Hallowe'en -- I'll be going to Hallowe'en parties on a small island this year, just for a change of pace.
[Eric is on vacation this week; this posting was pre-recorded]
The island won't protect you from zombies who walk along the ocean bottom...
Zombies make for such a better Halloween. Perhaps Zombie werewolves would be a nice combination.
Thank you for the two videos on covariance. Being able to see the actual coding is worth a thousand words.
In video #2 (7:26) you say:
"Covariance is always about stuff going out"
(So far, so good) Then you add:
"Contravariance is ALMOST always about stuff coming in (there are some exceptions to that rule)"
Maybe I already (and passively) know about them, but I can't figure that out right now: so please, could anyone tell more about those "complicated weird" situations ?
I think Eric meant the same kind of things as these he blogged about earlier: http://blogs.msdn.com/ericlippert/archive/2007/10/24/covariance-and-contravariance-in-c-part-five-higher-order-functions-hurt-my-brain.aspx
Thanks Joren; I did not check the history before 2008.
Re-read it and now it makes perfect sense.
I initially understood the statements in the video as equivalences (at least for the covariant part).
But since Meta<T> = Action<Action<T>> is covariant in T and stuff does not "go out", I was wrong.
So it seems the rule Eric states is merely:
- Stuff goes out? It's covariant.
- Stuff comes in? Chances are good it's contravariant, but no guarantee !
Halloween party on a small island? Reminds me of Jost Van ***.