interface method with readonly (const) parameters, not final

From: HK (pifpafpuf_at_gmx.de)
Date: 02/27/05


Date: 27 Feb 2005 03:14:19 -0800

What I would like to do is this:

public interface Boo {
  Boo mergeWith(Boo const other) const;
}

The intention would be to force an implementation
to not modify any of `this' or `other', but return either
one unchanged or create a freshly allocated object.

I read
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d658a6a2f00743de?tvc=2&q=readonly+method+parameters+final+
and
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4211070

but most of the discussion and proposed workarounds
relate to concrete implemented methods. Any ideas of how to
come at least close to the above other than by calling
the method only ever with copies of the original
things or write blurb in *BOLD* into the spec?

  Thanks,
  Harald.



Relevant Pages

  • Re: Friend Function in Template Class
    ... >> make it a simple const member function ... It is never a good idea to wite an output operator that takes a ... polymorphic printing. ... couldn't get from the public interface. ...
    (comp.lang.cpp)
  • Re: java final vs. c++ const
    ... > points to is a constant, while A* const p means p is a constant. ... > to achieve the first form in java? ... public interface Value extends UnmodifiableValue ...
    (comp.lang.java.programmer)
  • Re: interface method with readonly (const) parameters, not final
    ... "HK" schreef in bericht ... > public interface Boo { ... > Boo mergeWith(Boo const other) const; ...
    (comp.lang.java.programmer)