On 7/7/23 6:38 AM, IchorDev wrote:

Well yes, I even mentioned that in the OP. It's just that I'd expect using `static` "incorrectly" to cause an error, like `const` does. Instead, marking something as `static` *actually* does nothing, and nothing really tells you, so it causes a bit of a placebo effect.

D allows no-op attributes in many cases because you can possibly apply attributes to a group via `attribute:` or `attribute { ... }`, and you may not want to fine-tune which things can get the attribute to avoid errors.

Here's a fun one:

```d
enum foo() {
   return "what?";
}
```

What does this mean? `enum` is a storage class, and any storage class applied to a function is going to cause the function to be inferred return type. So effectively, the `enum` does nothing but take the place of `auto`. (`foo` is a function that returns `string`)

However, I can't think of a valid reason to allow `static` on a module-level scope. Applying static to a declaration at module-level should be a no-op. So maybe that's one "use" of static that can be eliminated.

-Steve
  • `static` on modu... IchorDev via Digitalmars-d-learn
    • Re: `static... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: `st... IchorDev via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... IchorDev via Digitalmars-d-learn
            • ... Steven Schveighoffer via Digitalmars-d-learn
              • ... Paul Backus via Digitalmars-d-learn
              • ... IchorDev via Digitalmars-d-learn

Reply via email to