Re: Static constructors in structs.

2015-10-30 Thread BBasile via Digitalmars-d-learn
On Friday, 30 October 2015 at 20:58:37 UTC, anonymous wrote: On 30.10.2015 21:23, TheFlyingFiddle wrote: Is this intended to work? struct A { __gshared static this() { //Add some reflection info to some global stuff. addReflectionInfo!(typeof(this)); } } I just

Re: Static constructors in structs.

2015-10-30 Thread BBasile via Digitalmars-d-learn
On Friday, 30 October 2015 at 21:29:22 UTC, BBasile wrote: On Friday, 30 October 2015 at 20:58:37 UTC, anonymous wrote: On 30.10.2015 21:23, TheFlyingFiddle wrote: Is this intended to work? struct A { __gshared static this() { //Add some reflection info to some global stuff.

Re: Static constructors in structs.

2015-10-30 Thread TheFlyingFiddle via Digitalmars-d-learn
On Friday, 30 October 2015 at 21:29:22 UTC, BBasile wrote: __gshared is mostly usefull on fields (eg public uint a) because it prevents a data to be put on the TLS, which in certain case reduces the perfs up to 30%. The byte code using a global variable that's not __gshared can be incredibly

Static constructors in structs.

2015-10-30 Thread TheFlyingFiddle via Digitalmars-d-learn
Is this intended to work? struct A { __gshared static this() { //Add some reflection info to some global stuff. addReflectionInfo!(typeof(this)); } } I just noticed this works in 2.069, is this intended? I mean I love it! It makes it possible to do lot's of useful mixins

Re: Static constructors in structs.

2015-10-30 Thread anonymous via Digitalmars-d-learn
On 30.10.2015 21:23, TheFlyingFiddle wrote: Is this intended to work? struct A { __gshared static this() { //Add some reflection info to some global stuff. addReflectionInfo!(typeof(this)); } } I just noticed this works in 2.069, is this intended? static

Re: Static constructors in structs.

2015-10-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 30 October 2015 at 20:23:45 UTC, TheFlyingFiddle wrote: I just noticed this works in 2.069, is this intended? I thought it always worked. The __gshared there I'm pretty sure doesn't do anything and should prolly be removed. The two forms are `static this` which is called for each

Re: Static constructors in structs.

2015-10-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 30 October 2015 at 21:29:22 UTC, BBasile wrote: __gshared is mostly usefull on fields (eg public uint a) That's only true if it is at the module level or static. Ordinary struct members are whatever the container is and class members are on the heap unless you do something fancy.

Re: Static constructors in structs.

2015-10-30 Thread TheFlyingFiddle via Digitalmars-d-learn
On Friday, 30 October 2015 at 20:58:37 UTC, anonymous wrote: On 30.10.2015 21:23, TheFlyingFiddle wrote: Is this intended to work? struct A { __gshared static this() { //Add some reflection info to some global stuff. addReflectionInfo!(typeof(this)); } } I just

Re: Static constructors in structs.

2015-10-30 Thread TheFlyingFiddle via Digitalmars-d-learn
On Friday, 30 October 2015 at 20:59:46 UTC, Adam D. Ruppe wrote: On Friday, 30 October 2015 at 20:23:45 UTC, TheFlyingFiddle wrote: But yeah, the struct feature table http://dlang.org/struct.html shows them as checked. I gotta say the language documentation is shaping up nicely.