is there any trait to check if variable is __gshared?
is there any trait to check if variable is __gshared? typeof() for '__gshared int' returns just 'int', whereas for 'shared int' it returns 'shared(int)'. can i check for __gshared storage class somehow?
Re: is there any trait to check if variable is __gshared?
I don't think so. Since __gshared isn't part of the type (unlike shared), you can't check for it with is(typeof()) and .stringof is only giving me the name.
Re: is there any trait to check if variable is __gshared?
ketmar: is there any trait to check if variable is __gshared? There isn't. It could be added to D if there's a significant reason. Why do you need it? Bye, bearophile
Re: is there any trait to check if variable is __gshared?
Why do you need it? i need to iterate over all module variables and 'register' (read: generate some wrappers) only for shared and __gshared ones, avoiding TLS. sure i can write a big WARNING in documentation, but i want to check it in compile time too. that's kind of 'in-game command console' module and i want to be able to write: mixin(CMDCON_REGISTER_VARS!modulename); which will iterate over all module vars and 'register' in console those which names stars with 'cvar_' and which are either 'shared' or '__gshared'. sorry for the messy explanation.
Re: is there any trait to check if variable is __gshared?
ketmar: i need to iterate over all module variables and 'register' (read: generate some wrappers) only for shared and __gshared ones, avoiding TLS. But why do you need to avoid the thread-local ones while crating your wrappers? (If your need is real, you can ask for the trait in the main D newsgroup). Bye, bearophile
Re: is there any trait to check if variable is __gshared?
But why do you need to avoid the thread-local ones while crating your wrappers? 'cause i need only 'old-style' globals in my console. there is no guarantee from which thread console command will be executed, and i don't really need TLS vars in it. that is the 'tech requirement'. (If your need is real, you can ask for the trait in the main D newsgroup). alas, i can't really explain why this is necessary for everyone (to be included in language). except that if we have such powerfull metaprogramming abilities we should be able to access any piece of 'type definition' (ok, technically __gshared is an attribute, i think) info that compiler knows. i think that '__gshared' should be part of type info, just like 'shared' is. variable can't be both 'shared' and '__gshared' anyway. i'll think about asking that though.
Re: is there any trait to check if variable is __gshared?
ketmar: 'cause i need only 'old-style' globals in my console. there is no guarantee from which thread console command will be executed, and i don't really need TLS vars in it. that is the 'tech requirement'. Is the -vtls compiler switch enough? Bye, bearophile
Re: is there any trait to check if variable is __gshared?
On Wednesday, 26 March 2014 at 15:58:32 UTC, bearophile wrote: Is the -vtls compiler switch enough? The JSON output with -X will also tell you if it is gshared. But in both cases you'd have to run the compiler twice and read the output instead of just getting the info at compile time from inside D.
Re: is there any trait to check if variable is __gshared?
Is the -vtls compiler switch enough? it's calling the external utility. i can use full blown D parser than. what i want is to be able to do that thing in compile time, just with metaprogramming.
Re: is there any trait to check if variable is __gshared?
On 3/26/14, ketmar nobodyherethismailsu...@gmail.com wrote: is there any trait to check if variable is __gshared? typeof() for '__gshared int' returns just 'int', whereas for 'shared int' it returns 'shared(int)'. can i check for __gshared storage class somehow? Please file this as an enhancement request to bugzilla[1]. Thanks! [1] : https://d.puremagic.com/issues/enter_bug.cgi?product=D
Re: is there any trait to check if variable is __gshared?
On 3/26/14, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Please file this as an enhancement request to bugzilla[1]. Thanks! [1] : https://d.puremagic.com/issues/enter_bug.cgi?product=D Ok filed as: https://d.puremagic.com/issues/show_bug.cgi?id=12474
Re: is there any trait to check if variable is __gshared?
Ok filed argh. should i (or moderators) close my report as duplicate then?
Re: is there any trait to check if variable is __gshared?
Please file this as an enhancement request to bugzilla[1]. Thanks! just did it: https://d.puremagic.com/issues/show_bug.cgi?id=12475 please check if i did it right and feel free to correct anything. i'm not english-speaking creature and i have no big expirience in doing public requests to big project. tnx.
Re: is there any trait to check if variable is __gshared?
On 03/26/2014 10:44 AM, ketmar wrote: Ok filed argh. should i (or moderators) close my report as duplicate then? Yes, please resolve it as a duplicate of the other bug (bug 12474). Ali
Re: is there any trait to check if variable is __gshared?
Yes, please resolve it as a duplicate of the other bug (bug 12474). done.
Re: is there any trait to check if variable is __gshared?
On Wed, 26 Mar 2014 11:52:29 -0400, ketmar nobodyherethismailsu...@gmail.com wrote: i think that '__gshared' should be part of type info, just like 'shared' is. variable can't be both 'shared' and '__gshared' anyway. The point of __gshared is it's an override of the type info. There are some cases where you need shared data, but you don't want the type system to know that. Usually it's for safety checks off code. -Steve