doc'ing intended const-qualification of references

  • Thread starter Andrew R. Thomas-Cramer
  • 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
 
A

Andrew R. 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top