I occasionally encounter the situation where a class instance holds some mutable state, which one specific part of the program is responsible for updating, and many parts of the program need read-only access to.
I am not worried about synchronizing accesses—the program may well be single-threaded. The important thing is that I need references to a class instance, where the holders of those references are not able to modify that instance.
Now, I could make an indirection layer—say, a struct holding a reference to the class instance, and exposing only the non-mutating parts of the API. But even that requires knowing which methods are non-mutating, and currently one is not allowed to mark members of a class as
Is there a recommended approach to this, and/or a plan to allow marking class members to indicate whether they mutate the instance?