Get body of a function as string

John Colvin john.loughran.colvin at gmail.com
Fri Jun 28 06:41:40 PDT 2013


On Friday, 28 June 2013 at 13:18:39 UTC, bearophile wrote:
> John Colvin:
>
>> Is there any way of getting the body of a function as a 
>> string? (Obviously only when the source code is available to 
>> the compiler)
>
> I think that currently there isn't a simple way to do it. What 
> is your use case?
>
> Bye,
> bearophile

I want to create a function with an identical body but different 
parameters: e.g. given a function

int foo(int a){ return a+1; }

automatically create a new function

int foo(int a)(){ return a+1; }


I'm trying to implement a sort of automatic compile-time currying.


More information about the Digitalmars-d-learn mailing list