Default method survey results

David Goodenough david.goodenough at linkchoose.co.uk
Thu Aug 16 06:54:08 PDT 2012


On Thursday 16 Aug 2012, Rémi Forax wrote:
> On 08/16/2012 11:47 AM, Maurizio Cimadamore wrote:
> > 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
> 
> but there will be no 1 to 1 mapping with the JVM bytecode,
> there is no default modifier in the generated class file as far as I 
know.
> 
> And for javadoc, it's often better to present information in a 
different
> way than the one given by the source,
> by example, you have all direct subtypes of a type even if you don't
> declare them in the source.
> 
> > *) 'default' is the dual of 'abstract' - it must be specified in
> > interfaces the same way as 'abstract' must be specified in classes
> 
> see Peter Levart answer, default is not the dual of abstract.
> The dual of abstract method is concrete method, which up to now, 
doesn't
> require any keyword.
> 
> > *) the presence of a keyword will help extending the syntax even more 
by
> > adding new default forms
> 
> the EG has rule out any extra syntax other than the classical syntax to
> declare a method body.
> 
> > *) 'default' summarises the semantics pretty well
> 
> We already have 'abstract' that mean should be implemented,
Surely 'abstract' means it MUST be implmented, and the new 'default' 
means is SHOULD be implemented.  It is actually one of the things that
Java lacks, that is to say a marker on a method that indicates to 
the IDE that the user should implement this method, but that they
do not have to.

David
> why do you want a keyword with the meaning, non-abstract but only in 
the
> case where the method is defined in an interface.
> 
> Moreover, non abstract method in interface change the way the VM
> populates the class vtable by using code of method declared in 
interfaces,
> so the semantics you're talking about, the semantics that change, is 
the
> semantics of 'implements',
> not the semantics of the non-abstract method by itself. (cf Stephen
> Colebourne reply)
> 
> > 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
> 
> Rémi



More information about the lambda-dev mailing list