Bug 18007 – Enforcing immutability

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2017-11-23T08:14:18Z
Last change time
2017-11-27T14:33:19Z
Keywords
C++
Assigned to
No Owner
Creator
Saanvi Sharma

Comments

Comment #0 by iamsaanvig — 2017-11-23T08:14:18Z
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
Comment #2 by slavo5150 — 2017-11-27T14:33:19Z
This looks like spam. Closing.