On 10/25/2011 02:23 PM, Jude Young wrote:
I'm sure that there is much more, but I immutable is set to global
storage and not Thread Local Storage.
I believe that const is stil TLS.
On Tue, Oct 25, 2011 at 5:15 AM, Gor Gyolchanyan
<[email protected] <mailto:[email protected]>> wrote:
What's the difference between const-declared variable and
immutable-declared variable?
module a;
const(int) a;
immutable(int) b;
void main()
{
}
Both are shared:
import std.stdio, std.concurrency;
immutable int x;
const int y;
void main(){
auto p=(cast(int*)&x);
*p = 1;
p=(cast(int*)&y);
*p = 2;
writeln(x, " ", y); // 1 2
spawn(function{writeln(x, " ", y);}); // 1 2
}