Compile-time global mutables
Paul Backus
snarwin at gmail.com
Thu Jun 30 13:01:23 UTC 2022
On Thursday, 30 June 2022 at 12:26:54 UTC, HuskyNator wrote:
> One example is generation of unique ID's (although there might
> be some workarounds)
Here's a mixin that works for this particular use-case:
```d
enum gensym = q{"_gensym" ~ __traits(identifier,
{})["__lambda".length .. $]};
// Works multiple times on the same line
pragma(msg, mixin(gensym)); pragma(msg, mixin(gensym));
```
More information about the Digitalmars-d
mailing list