Syntax for referencing a superinterface's default implementation seems backward

Kevin Campbell kevin_rec at 12doors.com
Sat Nov 17 22:28:11 PST 2012


The current syntax to reference a superinterface's default implementation
seems backwards. It seems more natural to put the modifier *before* the
specific interface name, not after. The keyword "super" can't be put first
while using a dot syntax, because that would cause a conflict with using
"super" to access the superclass's members. But how about changing the
syntax or using another word altogether?
 - current syntax -
    ScarySounds.super.growl(); // seems backward
- can't use "super" followed by a dot -
    super.ScarySounds.growl(); // interferes with reference to superclass
members ( named "MakeScarySound".)

- replace with -
    super::ScarySounds.growl();    // use a colon (or double colon, etc.)
- or -
    interfaces.ScarySounds.growl(); // use different keyword like
"interfaces", or "implemented"
- or -
    base.ScarySounds.growl(); // use keyword like "parents" or "inherited"
or "extended"
- or -
     base:ScarySounds.growl(); // use new keyword and a colon (or double
colon, etc.)


1) Switching the order and using a new keyword would make intuitive sense.
    Using a keyword such as "interfaces", etc. would obviously be the
*group* of all interfaces implemented by the class. Using a keyword like
"base", etc. would obviously be the group of all inherited elements, i.e.
the superclass and all implemented interfaces.

2) Using a keyword other than "super" would make more sense for the case
where an interface references the default implementation of a
superinterface. Interfaces don't have superclasses, so using the word
"super" isn't very appropriate.

interface ScarySounds{default void growl() { System.out.println("growl"); }
}
interface TerribleSounds extends ScarySounds {
    default void growl() { System.out.println("terrible");
ScarySounds.super.growl();
}

3) The format would also make more sense when chained or when combined with
other syntax.
If there are such cases.
class Class2 extends Class1 implements MonsterSounds {
    public void makeMonsterSound() {

inherited.MonsterSounds.inherited.TerribleSounds.inherited.ScarySounds.growl();
        // - or -  (assuming Class1 implements Interface1)
        //super.Interface1.super.makeScarySound(); // original syntax
        super.inherited.Interface1.makeScarySound();
    }


More information about the lambda-spec-observers mailing list