Wishlist proposal, documenting fn arg as in or out or mod
Cecil Ward
cecil at cecilward.com
Wed Jun 21 01:25:39 UTC 2023
On Wednesday, 21 June 2023 at 00:55:40 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> On 21/06/2023 3:01 AM, Cecil Ward wrote:
>> I would love to be able to document my arguments
>
> If you want a way to do it without compiler backed you can use
> UDA's:
>
> ```d
> void main() {
> func(2);
> }
>
> enum MyThing;
>
> void func(@MyThing int x) {
> }
> ```
Wow, I didn’t know that kind of tech was extensible like that. I
really need the checking that the compiler does though, on in for
example, making it const, and out presumably being either ref.
(Or input-output passing of registers, seeing as having to have a
pointer to a one machine word-sized value, say, that was in a
register only one nanosec ago, is a bit mad. One hopes that the
compilers might have a small size limit and switch to copy-by-ref
only if args width exceeds that size.)
That could give me a way of starting full documentation earlier
though.
More information about the Digitalmars-d
mailing list