Trait or builtin that returns arguments passed to current function (if any)
bauss
jj_1337 at live.dk
Thu Sep 9 09:28:17 UTC 2021
On Thursday, 9 September 2021 at 09:22:35 UTC, Dukc wrote:
> On Wednesday, 8 September 2021 at 21:53:21 UTC, Per Nordlöw
> wrote:
>> Adam, and like others including me, are longing for a
>> trait/builtin [1] that returns the parameters passed to the
>> function of the current scope (if any). Has such a thing been
>> proposed previously?
>>
>> [1]
>> http://dpldocs.info/this-week-in-d/Blog.Posted_2021_07_26.html#on-my-wish-list
>
> Why it should be a built-in? Apart from that requirement,
> `Parameters!(mixin(__FUNCTION__))` does the trick. A bit
> verbose but not much more so than the `__traits(...)` built-ins.
That doesn't do the same thing.
Parameters returns the type of each parameter.
__arguments in the case of OP holds the value of each parameter.
```d
Parameters!(mixin(__FUNCTION__))
```
Ex. for a function like:
```d
void a(int x, int y);
```
It'll actually give you:
```d
(int, int)
```
When really OP wants:
```d
[x, y]
```
More information about the Digitalmars-d
mailing list