digitalmars.D - Internal linkage - equivalent of C++ global static and anonymous
- Francesco Cattoglio (16/16) Jun 12 2014 Yesterday I discovered that a global static variable in D is just
- Kagamin (1/1) Jun 12 2014 Why private members can't have internal linkage?
- Francesco Cattoglio (4/5) Jun 12 2014 There has been some discussion about a few corner cases, see
- Dicebot (9/10) Jun 12 2014 tl; dr: because private provides zero guarantees that symbol
- Jacob Carlborg (4/5) Jun 12 2014 It's currently possible to access private symbols through pointers.
Yesterday I discovered that a global static variable in D is just a global variable, with no special rule about symbol visibility and such. I've scrolled quickly through old discussions on the NG and read the relevant DIP: http://wiki.dlang.org/DIP22 It seems to me that nobody thought about reusing the module keyword for declaring symbols with internal linkage. It would look like: file foo.d: module foo; // module declaration module uint cantSeeMe; // internal linkage attribute, hidden symbol private uint can_See_Me; // private, but symbol still visible AFAIK, module keyword right now is only used for module declaration, and is not valid anywhere else. Would it make sense to use it in this context, too?
Jun 12 2014
On Thursday, 12 June 2014 at 09:48:30 UTC, Kagamin wrote:Why private members can't have internal linkage?There has been some discussion about a few corner cases, see http://forum.dlang.org/thread/jlbsreudrapysiaetyrp forum.dlang.org?page=2#post-irrbdrxordjawkryvr b:40forum.dlang.org and following posts.
Jun 12 2014
On Thursday, 12 June 2014 at 09:48:30 UTC, Kagamin wrote:Why private members can't have internal linkage?tl; dr: because private provides zero guarantees that symbol won't be referenced in ABI context. It only controls direct language level access. It can possibly be done with analysis of all indirections but effort is not worth the gain. I think getting --gc-sections working out of the box is more worthy goal ( unfortunately last PR from Martin had no practical effect here :( )
Jun 12 2014
On 12/06/14 11:48, Kagamin wrote:Why private members can't have internal linkage?It's currently possible to access private symbols through pointers. -- /Jacob Carlborg
Jun 12 2014
On Thursday, 12 June 2014 at 14:23:59 UTC, Jacob Carlborg wrote:On 12/06/14 11:48, Kagamin wrote:And aliases with different qualifiers. And via return values. And with pretty much anything that does not require to type symbol identifier explicitly.Why private members can't have internal linkage?It's currently possible to access private symbols through pointers.
Jun 12 2014
On Thursday, 12 June 2014 at 14:48:41 UTC, Dicebot wrote:On Thursday, 12 June 2014 at 14:23:59 UTC, Jacob Carlborg wrote:http://blog.omega-prime.co.uk/?p=121On 12/06/14 11:48, Kagamin wrote:And aliases with different qualifiers. And via return values. And with pretty much anything that does not require to type symbol identifier explicitly.Why private members can't have internal linkage?It's currently possible to access private symbols through pointers.
Jun 13 2014
On Thursday, 12 June 2014 at 14:23:59 UTC, Jacob Carlborg wrote:On 12/06/14 11:48, Kagamin wrote:You don't need a symbol in the object file for that.Why private members can't have internal linkage?It's currently possible to access private symbols through pointers.
Jun 13 2014