PRE-PROPOSAL: Extension methods (original) (raw)
Rémi Forax forax at univ-mlv.fr
Thu Mar 19 08:10:31 PDT 2009
- Previous message: PRE-PROPOSAL: Extension methods
- Next message: PRE-PROPOSAL: Extension methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I vote NO. The problem with extension method is that it doesn't mix well with polymorphism.
Example: interface List { ... }
class Collections { public static void sort(this List<?> list) { // extension methods ... // 1 } }
class SortedList implements List { public void sort() { ... // 2 } }
import static java.util.Collections.*; ... List list=... list.sort(); // call 1
SortedList slist=... slist.sort(); // call 2
List slist2=slist; slist2.sort(); // call 1
The last call is not intuitive in a well known language in which late binding is the default behavior.
Rémi
- Previous message: PRE-PROPOSAL: Extension methods
- Next message: PRE-PROPOSAL: Extension methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]