I wonder if it would be possible to have a mechanism (either in scale or in dotty) that will enforce/guarantee immutability of data structures and/or functions?
I’m no compiler expert but it could be something like a new keyword or implicit argument required for doing reassignments. From what I understand on the lowest level reassignment is the only way to mutate something, so this should be enough.
I can recall that C++ has some pretty sophisticated const semantics similar to this, but I remember as well that it was pretty cumbersome to use it (I have not used C++ for more than a few years now, so don’t know whats the current status).
Thank you
Saanvi S
Scala Trainer: https://mindmajix.com/scala-training
Comment #1 by simen.kjaras — 2017-11-27T14:28:38Z
This bug report confuses me, so please provide some more information. D already has a mechanism for guaranteeing immutability for data structures and member functions - it's called immutable. Are you suggesting we add some feature to D that it doesn't already have? If so, explain how your suggestion differs from 'immutable'.
You mention 'scale' (which I take to be a misspelling of Scala?) and 'dotty', which seems to be a Scala library[1]. Have you perhaps posted this in the wrong Bugzilla?
[1]: https://github.com/lampepfl/dotty