digitalmars.D - Shallow constness?
- Maxime Chevalier-Boisvert (5/5) Jul 23 2013 Is there an attribute that can make member variables of a class
- Dicebot (6/9) Jul 23 2013 As far as I am aware, it is not a hack, but recommended practice.
Is there an attribute that can make member variables of a class read-only without having to declare them as const or immutable (const all the way down)? I saw that one can define a getter function without a setter to achieve this behavior, but that seems like a little bit of a hack.
Jul 23 2013
On Tuesday, 23 July 2013 at 18:01:58 UTC, Maxime Chevalier-Boisvert wrote:I saw that one can define a getter function without a setter to achieve this behavior, but that seems like a little bit of a hack.As far as I am aware, it is not a hack, but recommended practice. It actually does make sense - what you want has nothing to do with actual mutability of a member (at least within D concept of mutability) but is more like a tool for controlling access to it.
Jul 23 2013