Default method survey results
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
> >> the declaration site (probably written by someone else) will make
> >> absolutely no difference to the person who implements that
> >> 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
> > for that interface. Then you see a list of methods, some of which
> > 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
> > 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
> > one that mandates no keywords at all to denote an 'interface method
> > 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
> > 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
> And for javadoc, it's often better to present information in a
> 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,
> require any keyword.
> > *) the presence of a keyword will help extending the syntax even more
> > 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.
> why do you want a keyword with the meaning, non-abstract but only in
> 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
> so the semantics you're talking about, the semantics that change, is
> 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?
> > it must be more than just avoiding to type 'd' 'e' 'f' 'a' 'u' 'l'
> > which, as you say, probably somebody else would have typed in for you
> > Maurizio
More information about the lambda-dev