Extension method: Difference between revisions

Content deleted Content added
m Correct capitalization
rephrase
Line 5:
In [[object-oriented computer programming]], an '''extension method ''' is a [[Method (computer programming)|method]] added to an object after the original object was [[Compiler|compiled]]. The modified object is often a class, a prototype or a type. Extension methods are features of some object-oriented programming languages. There is no syntactic difference between calling an extension method and calling a method declared in the type definition.<ref name="ms_ext">{{cite web|url=http://msdn.microsoft.com/en-us/library/bb383977.aspx|title=Extension Methods|publisher=Microsoft|accessdate=2008-11-23}}</ref>
 
Not all languages implement extension methods in an equally safe manner, however. For instance, languages such as C#, Java (via Manifold), and Kotlin don't alter the extended class in any way, because doing so may otherwise break class hierarchies and interfere with virtual method dispatching. This is why these languages strictly implement extension methods statically and use static dispatching to invoke them.
[[Eric Lippert]], a principal developer on the C# compiler team, says "Extension methods certainly are not object-oriented."<ref>{{cite web|url=http://blogs.msdn.com/b/ericlippert/archive/2008/10/28/the-future-of-c-part-two.aspx|title=The Future of C#, Part Two - Fabulous Adventures In Coding|publisher=Microsoft}}</ref>