Questions tagged [immutable]
For questions about designing languages where data values are immutable and cannot be changed, or implementation aspects specifically related to immutability
8 questions
4
votes
2
answers
448
views
How do immutable compilers like Roslyn handle cyclic references in type definitions?
I'm learning about how modern compilers like Roslyn handle symbol tables and type information. From what I understand, Roslyn uses immutable data structures to represent symbols, which helps ensure ...
5
votes
1
answer
1k
views
Semantics on `with` keyword in C# for (heap-based) records
I have a question about a C# language design. Let's have a following code:
...
9
votes
6
answers
4k
views
Would it be safe to introduce the "freeze" statement?
Would it be safe to introduce the freeze statement for freezing a mutable object into an immutable object?
Such statement would mix well into dynamically-typed ...
12
votes
0
answers
325
views
How can a compiler optimise persistent data structures to use mutable data structures "under the hood"?
Consider for a motivating example a copy-on-write array, which implements a persistent (i.e. immutable) array data type. As an optimisation at runtime, a reference counter can be used to avoid the ...
2
votes
5
answers
1k
views
Is there any way a Java-like language could implement immutable primitive arrays without incurring performance penalties?
I asked: What prevents Java from having immutable primitive arrays? a while back and got an answer: Because immutable primitive arrays would typically require checking some immutable flag every time a ...
24
votes
7
answers
10k
views
Why do some languages have both immutable "variables" and constants?
Some programming languages (Rust is one I can think of off the top of my head) provides mechanisms to have immutable variables but they also have constants. Isn't an immutable variable just a constant?...
14
votes
5
answers
1k
views
What are the advantages and disadvantages of immutable languages?
This means variables can't be overwritten, arrays can't be modified, and nothing can be modified "in-place" - a new variable has to be created. Or if you need to modify it with a loop, then ...
11
votes
5
answers
846
views
What are the downsides of making all strings immutable to improve security and concurrency?
Many programming languages (such as Java) make strings immutable to mitigate many potential serious security threats.
Are there any major downsides or issues with a language having all strings ...