doc'ing intended const-qualification of references

  • Thread starter Thread starter Andrew R. Thomas-Cramer
  • Start date Start date
A

Andrew R. Thomas-Cramer

C#, like Java, fails to provide a const-qualifier for references for
compile-time const checking.

In Java, I used to document intended const-qualified references (e.g.,
method parameters) with C++ syntax: "const*". Does anyone have a better
suggestion, for C#?

The best I've come up with is "OBJECT READONLY", but that overloads an
existing C# keyword that means something else.


andy thomas-cramer
 
Several problems, including:
1) "Out" is already used in C# (and UML, Ada, PL/SQL,...) to refer to the
method parameter itself -- the reference -- rather than the object to
which it points. (The distinction between references and objects _is_
vital to the semantics, and confusion between the two has historically
caused trouble.)
2) "Out" does not apply to references other than method parameters, such
as those returned from a method, stored in instance/class members,
and local variables.
 
Back
Top