Extension vs defender methods

David Holmes david.holmes at oracle.com
Sun Nov 13 16:19:58 PST 2011


I think there is confusion about what is being added to the language 
versus the main use-cases for that thing.

"extension methods" comes from the ability to extend an existing 
interface in a source and binary compatible way with existing clients of 
that interface.

"defender methods" (previously 'miranda methods') comes from the same 
use-case but uses the quaint analogy to the legal system where if you 
don't have your own [lawyer|implementation] one will be provided for you.

The mechanism itself is neither of these things.

What is being added is a way to provide a default implementation for a 
method declared in an interface. It doesn't matter if that is a new 
method being added to the interface, or an existing method being 
updated, or whether the interface itself is being defined for the first 
time.

So while it has been somewhat useful to refer to "extension methods" and 
"defender methods" for the purposes of example and discussion I don't 
think this needs to be carried forward. There is no reason to give 
methods that have default implementations a special name - they are just 
regular interface methods for which a default implementation has been 
specified.

My 2c.

David Holmes


More information about the lambda-dev mailing list