Bug 2992 – std.typecons has unnecessary thread local globals
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-05-16T10:44:00Z
Last change time
2015-06-09T01:27:59Z
Keywords
performance
Assigned to
andrei
Creator
jason.james.house
Comments
Comment #0 by jason.james.house — 2009-05-16T10:44:29Z
The following is the offending code:
static string toStringHeader = Tuple.stringof ~ "(";
static string toStringFooter = ")";
static string toStringSeparator = ", ";
The variables should be declared invariant
Comment #1 by jason.james.house — 2009-05-16T10:55:25Z
On second thought, this may be an undocumented "feature" that allows changing how output formatting is handled. If that's true, the nature of this bug report is really much different. Use of globals for that purpose leaves residual side effects that can affect other calls to the function that expect/require normal handling. There are two basic options:
1. There should be a formatter struct that stores the customized state (the default free functions could simply call the formatting functions of the struct on an invariant global formatting struct.
2. Put these formatting arguments as default parameters on calls that use them
Comment #2 by andrei — 2009-05-17T19:56:20Z
(In reply to comment #1)
> On second thought, this may be an undocumented "feature" that allows changing
> how output formatting is handled. If that's true, the nature of this bug
> report is really much different. Use of globals for that purpose leaves
> residual side effects that can affect other calls to the function that
> expect/require normal handling. There are two basic options:
> 1. There should be a formatter struct that stores the customized state (the
> default free functions could simply call the formatting functions of the struct
> on an invariant global formatting struct.
> 2. Put these formatting arguments as default parameters on calls that use them
Yes, the plan was to allow people who prefer a different formatting to simply change the globals. I'm undecided how to proceed about this.
Comment #3 by andrei — 2009-08-27T19:28:25Z
I will close this bug for the time being.
Comment #4 by hskwk — 2009-10-05T22:31:17Z
(In reply to comment #2)
> Yes, the plan was to allow people who prefer a different formatting to simply
> change the globals. I'm undecided how to proceed about this.
These lines give me annoying compiler warnings with -vtls switch.
At least these global variables should be qualified as __gshared,
according to "Migrating to Shared" guideline.
Comment #5 by andrej.mitrovich — 2013-01-25T07:16:23Z