Yearly "can we please have void foo() auto" post
Paul Backus
snarwin at gmail.com
Thu Jul 27 18:55:25 UTC 2023
On Thursday, 27 July 2023 at 15:22:45 UTC, Anonymouse wrote:
> I love `auto`, it makes my life easier. The compiler infers
> what it can and I primarily enjoy the bonuses of `@safe`
> without having to annotate it manually.
>
> But it's not always applicable.
[...]
> Can we please have `void foo() auto`? It would behave as `auto
> foo()` does, except enforce the return type. As a bonus we'd
> also get `string bar() auto`.
IMO the correct solution is to just make the compiler infer
attributes like `@safe` for *all* functions, with exceptions only
in cases like `extern (C)` or virtual class/interface methods
where the full implementation is not available, or if the user
explicitly opts out (e.g., with something like `@noinfer`).
I have a half-written draft DIP for this that I plan to get back
to once Mike Parker announces that the DIP queue is open again.
If anyone else is working on this or wants to collaborate, please
let me know!
More information about the Digitalmars-d
mailing list