Visibility attributes for function and template parameters
Quirin Schroll
qs.il.paperinik at gmail.com
Thu Jun 27 17:26:29 UTC 2024
Let function and template parameters carry optionally a
visibility attribute. For example:
```d
void log(
string message,
private int line = __LINE__,
private string func = __FILE_FULL_PATH__
);
```
In another module, `log` can be called, but the `line` parameter
cannot be set explicitly as it’s not visible. That way, the
author or a library can ensure that magic default values for some
parameters are indeed applied. The user has the advantage that it
is harder to use such a function incorrectly, e.g. `log("current
step: ", i)` accidentally passes something entirely unrelated to
`line`.
Another example would be to alleviate the need for a `private`
overload that has more parameters and is called by the `public`
one.
More information about the dip.ideas
mailing list