Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 25, 2007 Q: (dmd 1.x) Difference between 'static const ...' and 'const ...' in templates | ||||
---|---|---|---|---|
| ||||
Hello.
For DMD 1.x, let's say I have the following template:
> template structname (S) {
> static const string structname = S.stringof[0..$-1];
> }
Is there any difference between 'static const ...' and 'const ...'?
Thanks.
Myron.
|
June 25, 2007 Re: Q: (dmd 1.x) Difference between 'static const ...' and 'const ...'in templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Myron Alexander | Reply to Myron,
> Hello.
>
> For DMD 1.x, let's say I have the following template:
>
>> template structname (S) {
>> static const string structname = S.stringof[0..$-1];
>> }
> Is there any difference between 'static const ...' and 'const ...'?
>
> Thanks.
>
> Myron.
>
I may be wrong but, unless you use it as a mixin or inside of a class/struct, I don't think so.
|
June 26, 2007 Re: Q: (dmd 1.x) Difference between 'static const ...' and 'const ...'in templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote: > Reply to Myron, > >> Hello. >> >> For DMD 1.x, let's say I have the following template: >> >>> template structname (S) { >>> static const string structname = S.stringof[0..$-1]; >>> } >> Is there any difference between 'static const ...' and 'const ...'? >> >> Thanks. >> >> Myron. >> > > I may be wrong but, unless you use it as a mixin or inside of a class/struct, I don't think so. > > More generally: Using 'static' at module-level scope does nothing. If the actual declaration ends up at some other scope (whether the template was mixed-in or is simply located somewhere other than module scope) then the 'static' will be meaningful. -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.org |
June 26, 2007 Re: Q: (dmd 1.x) Difference between 'static const ...' and 'const ...'in templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | Kirk McDonald wrote:
> BCS wrote:
>> Reply to Myron,
>>
>>> Hello.
>>>
>>> For DMD 1.x, let's say I have the following template:
>>>
>>>> template structname (S) {
>>>> static const string structname = S.stringof[0..$-1];
>>>> }
>>> Is there any difference between 'static const ...' and 'const ...'?
>>>
>>> Thanks.
>>>
>>> Myron.
>>>
>>
>> I may be wrong but, unless you use it as a mixin or inside of a class/struct, I don't think so.
>>
>>
>
> More generally: Using 'static' at module-level scope does nothing. If the actual declaration ends up at some other scope (whether the template was mixed-in or is simply located somewhere other than module scope) then the 'static' will be meaningful.
>
Thanks all.
Myron.
|
Copyright © 1999-2021 by the D Language Foundation