Yet yet yet yet another thread about const and immutable.
Timon Gehr
timon.gehr at gmx.ch
Tue Oct 25 05:50:44 PDT 2011
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
> <gor.f.gyolchanyan at gmail.com <mailto:gor.f.gyolchanyan at gmail.com>> 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
}
More information about the Digitalmars-d
mailing list