Ary Borenszweig wrote:
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() {}
final foo2() {}
ref foo3() {}
enum void foo5() {}
nothrow foo4() {}
pure foo6() {}
static int x1 = 10;
static x2 = 10;
void main() {}


I don't like that code, but I don't know if it's correct.

- What is a static global function in D?
- A final global function?
- Is that ref of void correct? (I think it is not)
- A enum of void function?
- What are global static variables in D?
- Are most of those attributes supposed to not need the "void"?


The following lines don't compile, is this supposed to be correct?
int static x3 = 10;
int enum x4 = 1;
int const x5 = 2;

Bye,
bearophile

I have discussed this subject many times, but it doesn't seem very important to the D dev team. IIRC they said it doesn't cause any harm.

But in some real code I have seen:

static int foo() { ... }

in global scope, and I always wondered why was that static there. Maybe the programmer thought static implied something there and now he's using it incorrectly, and now it confused me too and probably many others. So I think it is harmful because if the compiler allows such things than programmers can assume that must mean something.

Please don't confuse "it's not a high priority" with "it won't be fixed". There are nearly 900 open compiler bugs in Bugzilla, and we can only fix a couple of bugs per day. Compiler faults and wrong code generation always get top priority.

Reply via email to