www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18007] New: Enforcing immutability


          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

I’m no compiler expert but it could be something like a new keyword or
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

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

Thank you
Saanvi S
Scala Trainer: https://mindmajix.com/scala-training

Nov 23 2017