Name: rm29839 Date: 11/18/97 I'm not one of those people who want everything from c++ in java... I think however that java lacks the nicest feature of c++: const-qualifiers (and I'm not talking about const-fields - there's the final keyword for that), but I 'm talking about: void MyClass :: readMethod(const AType & a, AType & b) CONST { } Some advantages of const-qualifiers: - programmers can examine the behaviour of a method more easily - there's less ambiguity in the contract between the caller and the callee: - A caller doesn't have to worry about whether a method will (or will not) change a certain parameter. The method specifies in its signature whether a certain parameter is const or not => no ambiguity - When a method returns a private field, it can declare its return type to be constant so that nobody can modify the private field. class Test { private MyType field; MyType getField() { return field; // not safe!!! - what if some idiot does: new Test().getField().setSomeValue(....) } } I know that the contra against const qualifiers is that it isn't always easy, but isn't it possible to leave it as an option to the programmer whether he/she does or does not want to use const qualifiers? In case you are not going to do const-qualifiers in near future, then I would appreciate it very much if you could tell me the reason for not doing so. Thanks, geert mergan (###@###.###) last year computerscience (Review ID: 19924) ======================================================================
|