Friends in D, a new idiom?
Vijay Nayar
madric at gmail.com
Sun May 27 07:09:14 UTC 2018
On Sunday, 27 May 2018 at 06:37:56 UTC, IntegratedDimensions
wrote:
> I'm looking for something lightweight and direct. It is not for
> total encapsulation control but to simply provide an extra
> level of indirection for write access to make the object look
> read only to those that directly use it.
I think const is something that may be helpful then. If applied
consistently, especially with methods, it can also protect you
from accidentally making mutations in functions where were
originally intended to be read-only. Having an object "look"
read-only is more of a stylistic thing based on conventions about
method naming, etc. Personally I lean towards having the compiler
enforce it.
More information about the Digitalmars-d
mailing list