Default method survey results
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Aug 16 02:47:16 PDT 2012
On 16/08/12 10:13, Alex Blewitt wrote:
> The point of confusion - where the method is coming from - is at use
> site of the interface, not declaration site. What keywords you use at
> the declaration site (probably written by someone else) will make
> absolutely no difference to the person who implements that interface,
> keyword or not.
How do you get to know the set of methods that have to be implemented
when you implement an interface? Probably you go and look at the Javadoc
for that interface. Then you see a list of methods, some of which have
the D-word; you know that, at the very least (i.e. not to get
compile-time errors) you have to implement all the remaining ones (w/o
the D-word).
But I think we are a bit down into a syntactic rat-hole here - the
original question was - why not allowing a third option in the survey,
one that mandates no keywords at all to denote an 'interface method with
body'. The motivations behind the choice were several, including:
*) 'default' will make the interface code easier to parse
*) a keyword will provide an handy 1-1 mapping between source code and
Javadoc
*) 'default' is the dual of 'abstract' - it must be specified in
interfaces the same way as 'abstract' must be specified in classes
*) the presence of a keyword will help extending the syntax even more by
adding new default forms
*) 'default' summarises the semantics pretty well
What are the motivations behind leaving the 'default' keyword out? Note:
it must be more than just avoiding to type 'd' 'e' 'f' 'a' 'u' 'l' 't' -
which, as you say, probably somebody else would have typed in for you ;-)
Maurizio
More information about the lambda-dev
mailing list