is there a way to get the identifier (call it name) of what is being passed to a function ?

Paul Backus snarwin at gmail.com
Mon Jul 19 00:52:39 UTC 2021


On Monday, 19 July 2021 at 00:07:25 UTC, someone wrote:

> Every time I use it, of course, I have to double-type the tag 
> and the value. I wonder if there's some mechanism to just type 
> the following:
>
> ```d
> debugwriteln(lobjExchanges.count);
> ```
>
> ... and some way to get the identifier of what's being passed, 
> he.

The closest you can get is to use a string mixin:

```d
enum debugWriteln(string expression) =
     `writeln(q"(` ~ expression ~ `)", " = ", ` ~ expression ~ 
`);`;

// Usage:
mixin(debugWriteln!"lobjExchanges.count");
```


More information about the Digitalmars-d-learn mailing list