Get the code of any D-entity as string?

sighoya sighoya at gmail.com
Sun Dec 27 15:57:35 UTC 2020


On Sunday, 27 December 2020 at 14:40:01 UTC, Basile B. wrote:

>A more concrete example of what you are trying to achieve would
> allow to show the D way.


What happens with your code example for the struct:
```
struct S
{
     ulong[] a;
     @E(0) const int b=1;
     void v() const {return;}
     int v(int i) const {return i+1;}
}

```

Did I get the value/function body?

Even if get that some day, what about function/value declarations 
in the free scope (module scope)?

A realistic scenario would be mocking, you read in the 
declaration of the type to test and create mock variables for the 
variables referenced in the function body to decouple it from 
other modules.


More information about the Digitalmars-d-learn mailing list