PRE-PROPOSAL: Extension methods (original) (raw)
Reinier Zwitserloot reinier at zwitserloot.com
Wed Mar 18 13:28:46 PDT 2009
- Previous message: PRE-PROPOSAL: Extension methods
- Next message: PRE-PROPOSAL: Extension methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I don't think that's a relevant question.
import static java.util.Collections.sort;
List foo = something(); foo.sort();
That last line gets rewritten to:
Collections.sort(foo);
whether or not 'foo' is null does not change that rewrite. It's up the
sort method to react to the null. For consistency you could claim its
better that the runtime makes an explicit nullcheck here, I guess. But
then you'd be inconsistent with the desugaring to a static method call.
--Reinier Zwitserloot
On Mar 18, 2009, at 21:05, Mark Mahieu wrote:
2009/3/18 Neal Gafter <neal at gafter.com>
When an extension method has been statically imported, you can use it as if it is a member of the type of its first argument. Just out of curiosity, what do you think the behaviour should be when the 'first argument' is null? Put another way, from your experience would the model chosen here for C# be the right choice for Java? Mark
- Previous message: PRE-PROPOSAL: Extension methods
- Next message: PRE-PROPOSAL: Extension methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]