Getting function's AST at compile-time
deadalnix
deadalnix at gmail.com
Mon Sep 16 01:05:25 PDT 2013
On Sunday, 15 September 2013 at 22:59:37 UTC, Piotr Szturmaj
wrote:
> I'm looking for something like __traits(getAST, fn). The AST
> should represent only run-time (instantiated) code without any
> compile-time features.
>
> How hard it would be to implement this in the frontend?
>
> It would enable analysis of code at compile-time (without the
> need to modify the compiler).
That is something I'd like to see, but it has 2 difficult
pitfalls :
- Compile time feature aren't always well defined. What happen
if the AST of the function you look for depends on the CTFE you
are running ? Note that is can in very subtle manners.
- It require to define the AST properly. And then, every change
in the AST become a breaking change. That is really difficult,
especially since we are reluctant to clean up some
implementations quirks (some even consider them as feature).
More information about the Digitalmars-d
mailing list