On Sunday, 29 November 2026 at 19:16:44 UTC, Forum User wrote:
One reason D allows them is because of code generation.

Everything that is not forbidden is allowed. It's not forbidden.

But what about warnings on unused variables of non-trivial type:

```
void main() {

   size_t a;
   Lock b;

   a = 1;
}
```

Warnings exist to notify a user that something might go or is going wrong. There is nothing wrong with unused variables. Special cases about when a warning triggers is more confusing than helpful.

Or unused function arguments:

```
void foo (ref size_t a, size_t b) {

   a = 1;
}
```

Shall it warn?

No, because you might want them in the future. Unused function parameters are a way to future proof your API and not break user code.
  • Compiler doesn't... DLearner via Digitalmars-d-learn
    • Re: Compile... jmh530 via Digitalmars-d-learn
    • Re: Compile... Kapendev via Digitalmars-d-learn
      • Re: Com... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Com... Mindy Batek (0xEAB) via Digitalmars-d-learn
      • Re: Com... Forum User via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... Kapendev via Digitalmars-d-learn
        • Re:... Kapendev via Digitalmars-d-learn

Reply via email to