Get the code of any D-entity as string?

sighoya sighoya at gmail.com
Fri Dec 25 21:25:40 UTC 2020


I've read a bit in Dlang traits.

It now has the ability to retrieve all method signatures of an 
overload set.
Big plus from me.

Is generally possible to get the declaration of a 
type/module/value as string in traits?

I didn't have any concrete use case for it, but it would 
essentially allow us to reflect over any code (we may have to 
respect privacy, of course).

On top of that, people could write their own token or ast 
frameworks as library solutions.

Further, most of the trait functionality given in the trait 
library could be simply implemented as a library solution.

I don't know D enough to be sure it isn't yet possible. 
Theoretically, we could read all files in a source folder, but I 
want also to read declarations from types outside my source 
folders, e.g. from those located in dyn libs.


More information about the Digitalmars-d-learn mailing list