digitalmars.D.learn - is there any trait to check if variable is __gshared?
- ketmar (4/4) Mar 26 2014 is there any trait to check if variable is __gshared? typeof()
- Adam D. Ruppe (3/3) Mar 26 2014 I don't think so. Since __gshared isn't part of the type (unlike
- bearophile (5/6) Mar 26 2014 There isn't. It could be added to D if there's a significant
- ketmar (12/13) Mar 26 2014 i need to iterate over all module variables and 'register' (read:
- bearophile (6/9) Mar 26 2014 But why do you need to avoid the thread-local ones while crating
- ketmar (13/17) Mar 26 2014 'cause i need only 'old-style' globals in my console. there is no
- bearophile (4/8) Mar 26 2014 Is the -vtls compiler switch enough?
- Adam D. Ruppe (5/6) Mar 26 2014 The JSON output with -X will also tell you if it is gshared.
- ketmar (3/4) Mar 26 2014 it's calling the external utility. i can use full blown D parser
- Steven Schveighoffer (6/8) Mar 26 2014 The point of __gshared is it's an override of the type info. There are
- Andrej Mitrovic (3/7) Mar 26 2014 Please file this as an enhancement request to bugzilla[1]. Thanks!
- ketmar (5/7) Mar 26 2014 just did it: https://d.puremagic.com/issues/show_bug.cgi?id=12475
- Andrej Mitrovic (3/5) Mar 26 2014 Ok filed as:
- ketmar (1/2) Mar 26 2014 argh. should i (or moderators) close my report as duplicate then?
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (3/5) Mar 26 2014 Yes, please resolve it as a duplicate of the other bug (bug 12474).
- ketmar (1/3) Mar 26 2014 done.
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?
Mar 26 2014
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.
Mar 26 2014
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
Mar 26 2014
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.
Mar 26 2014
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
Mar 26 2014
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.
Mar 26 2014
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
Mar 26 2014
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.
Mar 26 2014
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.
Mar 26 2014
On Wed, 26 Mar 2014 11:52:29 -0400, ketmar <nobodyherethismailsucks 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
Mar 26 2014
On 3/26/14, ketmar <nobodyherethismailsucks 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
Mar 26 2014
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.
Mar 26 2014
On 3/26/14, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:Please file this as an enhancement request to bugzilla[1]. Thanks! [1] : https://d.puremagic.com/issues/enter_bug.cgi?product=DOk filed as: https://d.puremagic.com/issues/show_bug.cgi?id=12474
Mar 26 2014
Ok filedargh. should i (or moderators) close my report as duplicate then?
Mar 26 2014
On 03/26/2014 10:44 AM, ketmar wrote:Yes, please resolve it as a duplicate of the other bug (bug 12474). AliOk filedargh. should i (or moderators) close my report as duplicate then?
Mar 26 2014
Yes, please resolve it as a duplicate of the other bug (bug 12474).done.
Mar 26 2014