By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,338 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,338 IT Pros & Developers. It's quick & easy.

doc'ing intended const-qualification of references

P: n/a
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


Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Simon Trew" <ten.egnaro@werts> writes:
Ada uses "in", "out", and "in out". Some people might be skeetish about this
and say that the "objects" passed are values, they are just the values of
the references-to-object, but that is by the by I think as far as the
semantics of the thing are concerned. I think "In", "Out", and "In Out" are
common enough, and although it is late I seem to recall they occur in the
proposed Action Semantics addendum(?) to the UML. S. Andrew R. Thomas-Cramer <ar**@shell.core.com> wrote in message
news:vg************@corp.supernews.com...
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

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.