[cpp-threads] static locals

Peter Dimov pdimov at mmltd.net
Sun May 29 10:09:45 BST 2005


Kevlin Henney wrote:
> In message <03d701c562fb$77e86740$6401a8c0 at pdimov2>, Peter Dimov
> <pdimov at mmltd.net> writes
>> Andrei Alexandrescu wrote:
>>> Alexander Terekhov wrote:
>>>> static(synchronized) X * p = new X;
>>>
>>> So 'synchronized' would be a contextual keyword. C++ doesn't have
>>> any (although I personally like them), and as such we might
>>> encounter resistance.
>>>
>>> Maybe the uglier
>>>
>>> static "once" vardecl
>>>
>>> might have more success.
>>
>> What's wrong with Hans's original suggestion of protected static? It
>> doesn't require a new keyword or contextual syntax.
>
> I think it is perhaps worth taking a step back and nipping a trend in
> the bud before it messes things up too much.

[...]

> C++ currently lacks what MIDL and C# refer to as attributes and Java
> refers to as annotations, but I guess something like that is
> essentially what seems to make sense here. Does anyone know if there
> are any proposals on the table for C++ in this area? I can't recall
> anything off the top of my head. Either the MS way of using [...] to
> enclose attribute information or the style that Andrei mentioned
> above, based on string literals. This latter form has the advantage
> that there is already prior art for it in C++, namely the linkage
> specifier, eg extern "C". So protected static would become something
> like static "synchronized", __async would become something like
> volatile "thread", with the default meaning of volatile being
> something like volatile "signal", and so on.

My opinion is that all local statics should be synchronized (as in the IA64 
ABI) and that __async volatile should not be introduced. So... if I take a 
step back I see no need for new syntactic additions. ;-)

That aside, static is a storage class, but volatile is a cv qualifier; 
adding arbitrary "attributes" to cv qualifiers and into the type system 
would be a big change. 





More information about the cpp-threads mailing list