On Sunday, 12 June 2022 at 18:45:27 UTC, Paul Backus wrote:
On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote:
[...]
[...]
[...]

Here's a `gensym` implementation I came up with a while back:

```d
enum gensym = q{"_gensym" ~ __traits(identifier, {})["__lambda".length .. $]};

// Works multiple times on the same line
pragma(msg, mixin(gensym)); pragma(msg, mixin(gensym));
```

This takes advantage of the fact that the compiler generates a unique identifier for every lambda function it encounters. While you can't actually use those identifiers in your code, they are visible in error messages and can be accessed via `__traits(identifier)`.

Hi,

This is great thanks.

Reply via email to