C++ frequently questioned answers

Ary Borenszweig ary at esperanto.org.ar
Mon Oct 29 04:42:04 PDT 2007


Matti Niemenmaa escribió:
> Frits van Bommel wrote:
>> Regan Heath wrote:
>>> Ary Borenszweig wrote:
>> [snip normal "static this" version]
>>>> 2.
>>>> ---
>>>> import std.stdio;
>>>>
>>>> class X {
>>>>     static {
>>>>             this() {
>>>>         writefln("static");
>>>>             }
>>>>     }
>>>> }
>>>>
>>>> void main() {
>>>> }
>>>> ---
>>> Has this been reported as a bug?
>> IIRC Walter has said that "static this" needs to be two adjacent tokens
>> for it to be parsed as such, and this is not a bug but working as designed.
> 
> And it's not only "Walter said", it's been explicitly stated in the doc for as
> long as I can remember: http://digitalmars.com/d/1.0/class.html#StaticConstructor
> 
> "The static in the static constructor declaration is not an attribute, it must
> appear immediately before the this"
> 

Yeah, for me it's not a bug either. I just wanted to point out that also 
in D there are some things that may not be that obvious to a newcomer. 
But it's not a big deal (same as "void foo()" isn't a big deal in the 
previous example).



More information about the Digitalmars-d mailing list