November 23, 2017
https://issues.dlang.org/show_bug.cgi?id=18007

          Issue ID: 18007
           Summary: Enforcing immutability
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dlang.org
          Assignee: nobody@puremagic.com
          Reporter: iamsaanvig@gmail.com

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

--