cosinus wrote:
So my question is would it be a good idea to have some kind of implicit
declarations of variables that are used as parameters:
```D
int add(decl ref int c, int a, int b);
// ...
// c is unknown here
if(add(c, 123, 456)) {
writeln("error!");
}
// c is implicit declared at the function-call above.
assert(c == 579);
```
D already has one such construct, `foreach`. and it is a huge misdesign. it
is *absolutely* not clear from the code that `c` is introduced by a
function call. exactly like with `foreach (c; ...)`, any sane person
expects that just using variable name without any type prepended means
"let's use already declared variable `c`". the ONLY place where this
uniformity is broken now is `foreach`, and this is already bad.
note that D devs stubbornly insists that `auto` is not a type placeholder,
but a storage qualifier, like `static`, so you can't write `foreach (auto
c; ...)` (and compiler rejects such code). yet, `if (auto c = ...)` is
perfectly allowed, and here `auto` is type placeholder. talking about
consistency, yeah.
anyway, adding yet another broken promise (aka illogical inconsistency)
into language won't do any good. each inconsistency makes code harder to
read and understand.