https://issues.dlang.org/show_bug.cgi?id=9088
Mathias LANG changed:
What|Removed |Added
Status|NEW |RESOLVED
CC|
http://d.puremagic.com/issues/show_bug.cgi?id=9088
Andrej Mitrovic andrej.mitrov...@gmail.com changed:
What|Removed |Added
CC|
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
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
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
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
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
. 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
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
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
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
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;
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
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
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
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
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
Yigal Chripun wrote:
I wonder, how do other languages treat static variables inside templated
functions?
C++ generates a different variable for each instantiation.
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
19 matches
Mail list logo