Transform a function's body into a string for mixing in
Max Haughton
maxhaton at gmail.com
Thu Jun 20 19:27:38 UTC 2019
On Thursday, 20 June 2019 at 19:09:11 UTC, Emmanuelle wrote:
> Hello!
>
> Is there any trait or Phobos function for transforming a
> function/delegate/lambda/whatever's body into a string suitable
> for `mixin(...)`? For example:
>
> ---
> __traits(getBody, (int a, int b) => a + b); // returns "(int a,
> int b) => a + b"
> // or maybe just "a
> + b"
> ---
>
> If not, is there any way to do this _without_ using strings?
> They are very inconvenient and could hide errors.
>
> Thanks!
We don't have anything AST-macro ish or a trait as described.
The trait isn't impossible to implement but I could imagine it
being a nightmare for compile times
More information about the Digitalmars-d-learn
mailing list