[Issue 9088] static static

2018-10-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9088 Mathias LANG changed: What|Removed |Added Status|NEW |RESOLVED CC|

[Issue 9088] static static

2012-11-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9088 Andrej Mitrovic andrej.mitrov...@gmail.com changed: What|Removed |Added CC|

[Issue 9088] static static

2012-11-29 Thread d-bugmail
and replacing them with a jump to just one implementation). I agree that in theory the compiler can avoid creating those copies in the first place, because it knows they come from a template, but I think currently LDC2 is not this smart; - A static static annotation is a contract between compiler and programmer

[Issue 9088] New: static static

2012-11-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9088 Summary: static static Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD

static static again

2011-08-21 Thread bearophile
A not too much serious post fit for a slow Sunday :-) Time ago I have half-seriously suggested the static static, to be used to define a static variable that is static (shared) for all instantiations of one function template. With it you avoid a global variable, and you have the advantages

Re: static static

2009-11-12 Thread Steven Schveighoffer
On Tue, 10 Nov 2009 16:56:11 -0500, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: What's the advantage over: static int y; T foo(T)(T x) { // ... } That the global name space is kept clean, the y name can be seen only inside foo. Reducing the visibility of names

Re: static static

2009-11-12 Thread bearophile
Steven Schveighoffer: Doesn't static do that already? I mean keep y within the module namespace. Sure, it's visible to other functions in foo's module, but not the global namespace. Or does that not work in D... I think that 'private' is able to keep a name private to a module... But I

Re: static static

2009-11-11 Thread Yigal Chripun
. In the situations where LTO is available I think this doesn't cause problems. Then I am half-seriously proposing a syntax like: T foo(T)(T x) { static static int y; // ... } Where the y is now static to (shared among) all instances of the templated function foo. This may be a little error-prone

Re: static static

2009-11-11 Thread Andrei Alexandrescu
template instance. In the situations where LTO is available I think this doesn't cause problems. Then I am half-seriously proposing a syntax like: T foo(T)(T x) { static static int y; // ... } Where the y is now static to (shared among) all instances of the templated function foo. This may

Re: static static

2009-11-11 Thread Bill Baxter
On Wed, Nov 11, 2009 at 1:16 PM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: One option that hasn't been mentioned: private ref int myInt() {    static int theInt;    return theInt; } void fun(T)(T arg) {    ... use myInt() ... } Is that a joke? That just replaces global

Re: static static

2009-11-11 Thread Andrei Alexandrescu
Bill Baxter wrote: On Wed, Nov 11, 2009 at 1:16 PM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: One option that hasn't been mentioned: private ref int myInt() { static int theInt; return theInt; } void fun(T)(T arg) { ... use myInt() ... } Is that a joke? That just

Re: static static

2009-11-11 Thread Bill Baxter
On Wed, Nov 11, 2009 at 1:36 PM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: Bill Baxter wrote: On Wed, Nov 11, 2009 at 1:16 PM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: One option that hasn't been mentioned: private ref int myInt() {   static int theInt;  

Re: static static

2009-11-10 Thread Yigal Chripun
to use true global variables/constants (but if you use link-time optimization then LDC is able to remove such shared constants). So I was thinking about a static static attribute that avoid moving the statics to globals. Is this a useless idea? Bye, bearophile Regardless of usefulness (or good

Re: static static

2009-11-10 Thread bearophile
LTO is available I think this doesn't cause problems. Then I am half-seriously proposing a syntax like: T foo(T)(T x) { static static int y; // ... } Where the y is now static to (shared among) all instances of the templated function foo. This may be a little error-prone and maybe

Re: static static

2009-11-10 Thread Steven Schveighoffer
if such constants are present in more than one template instance. In the situations where LTO is available I think this doesn't cause problems. Then I am half-seriously proposing a syntax like: T foo(T)(T x) { static static int y; // ... } Where the y is now static to (shared among) all

Re: static static

2009-11-10 Thread Bill Baxter
if such constants are present in more than one template instance. In the situations where LTO is available I think this doesn't cause problems. Then I am half-seriously proposing a syntax like: T foo(T)(T x) {  static static int y;  // ... } Where the y is now static to (shared among) all instances

Re: static static

2009-11-10 Thread bearophile
Steven Schveighoffer: What's the advantage over: static int y; T foo(T)(T x) { // ... } That the global name space is kept clean, the y name can be seen only inside foo. Reducing the visibility of names is useful to keep things tidy. (Inside normal functions in D static has just

Re: static static

2009-11-10 Thread Walter Bright
Yigal Chripun wrote: I wonder, how do other languages treat static variables inside templated functions? C++ generates a different variable for each instantiation.

Re: static static

2009-11-10 Thread Walter Bright
bearophile wrote: Steven Schveighoffer: What's the advantage over: static int y; T foo(T)(T x) { // ... } That the global name space is kept clean, the y name can be seen only inside foo. Reducing the visibility of names is useful to keep things tidy. (Inside normal functions in D static