Default method survey results
Jim Gish
jim.gish at oracle.com
Wed Aug 15 15:43:14 PDT 2012
On 08/13/2012 10:24 AM, Maurizio Cimadamore wrote:
> On 13/08/12 15:09, Jose A. Illescas wrote:
>> Gregg,
>>
>> Compiler can add "default" keyword for every method (on interface)
>> with implementation (delimiteded with "{...}" instead of "default")
>>
>> Demarcations on developer hands are ugly, (I think) must be resolved
>> by compiler...
> In the Java land we tend to adhere to the general principle of 'reading
> is more important than writing' - can the 'default' keyword be omitted
> in principle? Yes, it is indeed trivial to do so in the compiler. Do we
> really want to go down that path? I don't think so, for the following
> reasons:
>
> *) a keyword (like default) at the beginning of the method declaration
> will make it very clear and unambiguous that the following method
> declaration is kinda special. Of course you could 'infer' the same
> information by looking as to whether the method has a body or not, but
> it's also a matter of clarity (think of cases where you have multiple
> thrown types, annotations, etc.).
>
I agree, Maurizio. To quote the old song title "Don't let me be
misunderstood" There is considerable value in making one's intentions
clear. In the case where we are deviating from the long-standing
construct/constraint of no methods defined in interfaces, having to be
explicit by saying "default" or something else, makes it clear that you
know what you are doing, that in fact, it is your intention to do
something special here.
Jim
More information about the lambda-dev
mailing list