YaaaaY! So, what the heck am i screaming about :)
Alright non-technical folks, am gonna disappoint you, this is purely a tech post.
So, there is this spec for partial methods in C# :
http://msdn.microsoft.com/en-us/library/wa80x488.aspx
And the very last line says:
You cannot make a delegate to a partial method.
Why:
Am not pretty sure of the reason behind this design decision, but one of my friend points out that the reason could be,
say you have a partial method declaration like partial void foo();
and a partial method implementation like
partial void foo()
{
}
Lets say now that you make a delegate to Foo, and after sometime, you may choose to remove the implementation from the code. So partial methods allow the impl to be removed and declaration to still be there. But still you'll have your delegate pointing to foo and it will result in a build failure for the project and may be they preferred not to encourage such confusions?
Alright, whats the big deal about it?
Well, have u tried creating a delegate to a partial method ever?
Darn it, it works! I mean the C#3.0 compiler shipped with Visual Studio 2008, accepts a delegate to a partial method.
Well its not a tricky bug or a gotcha in the C# compiler that i stumbled upon, but a mere non-adherence to the compiler spec(the ultimate authority).
I even thought it could be a documentation defect but turns out that its not so. Right now, the C# team is investigating this.
Anyway, finding a bug in the shipped C# compiler is something that i could scream about... so, YaaaaY !
This entry was posted
on 11:26 PM
and is filed under
C#,
Tech Talk
.
You can leave a response
and follow any responses to this entry through the
Subscribe to:
Post Comments (Atom)
.
9 comments