Tidy attributes

Pelle Månsson pelle.mansson at gmail.com
Thu Mar 11 13:41:18 PST 2010


On 03/11/2010 10:20 PM, bearophile wrote:
> While looking for possible attribute problems to add to Bugzilla, I have seen the following D2 program compiles and runs with no errors or warnings:
>
>
> static foo1() {}

static does not apply to free functions, I would guess this means the 
same as auto.

> final foo2() {}
> ref foo3() {}
> enum void foo5() {}

Wow.

> nothrow foo4() {}
> pure foo6() {}

Would guess for auto here. Not tidy, as you say :)

> static int x1 = 10;
> static x2 = 10;

static here means 'known at compile time', I think.

> - What is a static global function in D?

It means nothing, but I can't seem to find the documentation. It's just 
ignored.

> - A final global function?
> - Is that ref of void correct? (I think it is not)
> - A enum of void function?

These are mysteries.

> - What are global static variables in D?

variables evaluated at compile time, for example

int cfte_able_function() {
     return 14423 + 12341;
}

int other_function() {
     writeln("Not cfte");
     return 7;
}

static x1 = 123; //works
static x2 = cfte_able_function; //works;
static x3 = other_function; //cannot evaluate other_function() at 
compile time

As you say, these are odd issues indeed. :)


More information about the Digitalmars-d-learn mailing list