immutable data

R

Richard Clafton

Hello (e-mail address removed),
What does the term immutable mean? Could you please explain me with
examples.

Google is your friend when looking for definitions....

Enter into google:

define:immutable object
 
T

tomk148

"LOLRTFM"

immutable objects are significant because of how the compiler will
deal with them. for instance C# strings are immutable, so if you say

string s = "bl";
foreach (int i=0; i<10; i++)
s += "a";
s+= "h";

the end result is what you think it would be, but the compiler will be
creating lots more temporary strings in between.

"bla", "blaa", "blaaa" ... etc

if strings weren't immutable you wouldn't have as many temporary
objects, but things maintenance behind the scenes would be slower.
When objects are immutable the compiler has more assumptions to work
on and will be faster in the long run (assuming you avoid stuff like
the above). So if something is immutable you should be aware of
temporary object creation getting out of hand.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top