Re: Static attributes aren' immutable

2010-03-05 Thread bearophile
div0: > Somebody want to post in the main group? OK, I'll do it soon :-) Bye, bearophile

Re: Static attributes aren' immutable

2010-03-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Pelle Månsson wrote: > On 03/05/2010 07:50 PM, bearophile wrote: >> div0: >>> putting it in Foo simply puts it in a namespace.< >> >> So my (wrong) idea of immutable applied to a struct was that every >> thing in such namespace becomes immutable (I thi

opEquals among types

2010-03-05 Thread bearophile
This D2 program compiles and works correctly: import std.c.stdio: printf; auto add(T1, T2)(T1 x, T2 y) { if (!is(T1 == T2)) printf("Different types\n"); return x + y; } void main() {} But do you know why D2 needs that is() there? Can't it be removed, like this? (doesn't work):

Re: Static attributes aren' immutable

2010-03-05 Thread Pelle Månsson
On 03/05/2010 07:50 PM, bearophile wrote: div0: putting it in Foo simply puts it in a namespace.< So my (wrong) idea of immutable applied to a struct was that every thing in such namespace becomes immutable (I think this is a bit more intuitive). What do you think of modifying D2 so in a sit

Re: Static attributes aren' immutable

2010-03-05 Thread bearophile
div0: >putting it in Foo simply puts it in a namespace.< So my (wrong) idea of immutable applied to a struct was that every thing in such namespace becomes immutable (I think this is a bit more intuitive). What do you think of modifying D2 so in a situation like the one I've shown even static a

Re: Static attributes aren' immutable

2010-03-05 Thread Lars T. Kyllingstad
bearophile wrote: I'm playing some more with immutables in D2. This program compiles: struct Foo { static int x; } void main() { immutable Foo f; Foo.x++; f.x++; } Is this code supposed to be correct? If I have an immutable struct I want all of it to be immutable... Bye and th

Re: Static attributes aren' immutable

2010-03-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bearophile wrote: > I'm playing some more with immutables in D2. This program compiles: > > struct Foo { > static int x; > } > void main() { > immutable Foo f; > Foo.x++; > f.x++; > } > > Is this code supposed to be correct? If I have

Static attributes aren' immutable

2010-03-05 Thread bearophile
I'm playing some more with immutables in D2. This program compiles: struct Foo { static int x; } void main() { immutable Foo f; Foo.x++; f.x++; } Is this code supposed to be correct? If I have an immutable struct I want all of it to be immutable... Bye and thank you, bearophile