Default methods syntax survey

Paul Benedict pbenedict at apache.org
Tue Aug 7 09:00:57 PDT 2012


Lukas,

I don't think #3 is an option because interfaces with method bodies
are unnatural to begin with. At least specifying the "default" keyword
gives the reader some context why the language allows a method body.
Personally, I wish interfaces would remain as pure contracts (without
implementation), but I don't know of a better option to evolve
interfaces.

Paul

On Tue, Aug 7, 2012 at 10:49 AM, Lukas Eder <lukas.eder at gmail.com> wrote:
>> Here is a one-question syntax survey on default methods for Java SE 8:
>>   https://www.surveymonkey.com/s/9VPJZQQ
>>
>> Feel free to republish elsewhere; survey will close on Friday of this week.
>
> Since opinions on the position of "default" are welcome, I hope it's
> not spam if I ask again, why option 3 is not an option:
>
> 1.  void foo() default {
>          System.out.println("foo");
>      }
>
> 2.  default void foo() {
>          System.out.println("foo");
>      }
>
> 3.  void foo() {
>          System.out.println("foo");
>      }
>
> The survey question states the following:
>
>>  in the same way we can have static methods, abstract methods, etc, and the keyword takes the same place as abstract or static would. Which feels more natural?
>
> I feel that the "default" keyword doesn't feel very natural at all.
> The fact that the method has a body is expressive enough to indicate
> that it is a "default" method. Classes don't have default methods
> either, although class methods behave in similar ways as default
> methods... I know that "final" is out of scope for Java 8, just like
> "static". Yet, thinking about "final default" or "default final" or
> "static default" really doesn't feel natural.
>
> After this, I promise, I won't try my luck again on having default removed :-)
>


More information about the lambda-dev mailing list