TWiki . Dev . SuperCall

This page documents the current super mechanism in Nice. It compares it with super in Java, and calls for discussion on ehancements. First, it does not make sense to just copy Java's semantics. In Java you write:

class B extends A
{
  void m(int x) { super.m(x); ... }
}
So super in Java means roughly "fetch the following method in my superclass". With multi-methods this does not make sense, since methods consider all arguments to choose the implementation, not just the first one.

Another odity with Java is that you call call a different method than the current one, or pass it other arguments than the arguments of the current method. I think at least that calling the same method with the same arguments is by far the most common, so it should be more natural to do it, without having to reapeat the method name and arguments.

So the current definition in Nice is that super is an expression that calls the next implementation of the current method, with the same arguments. So the example would become:

class B extends A
{
  m(x) { super; ... }
}

I would be interested to hear if other cases are useful in practice (calling a different method, or passing different arguments). These pose more theoretical problems. For instance the Dylan language says that passing different arguments is fine as long as they will result in the same implementation to be chosen, otherwise the result is undefined.

-- DanielBonniot - 12 Jul 2002

I have used super with different arguments in the case of constructors in Java. They are used to set default or constant values for the base class.

Could you give a price example?

-- ArthurSmyles - 10 Apr 2003

----- Revision r1.3 - 11 Apr 2003 - 22:01 GMT - DanielBonniot
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.